Reorganization - Start working on DSL API.

This commit is contained in:
Joshua Bemenderfer
2022-11-01 14:39:30 -04:00
parent 9b5ac14082
commit 403b6d1768
18 changed files with 2209 additions and 611 deletions

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 Joshua Michael Bemenderfer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,34 @@
import {unified} from 'unified'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import rehypeStringify from 'rehype-stringify'
export default function (config) {
return async function ({ lineData, ended, next }) {
if (ended) return ''
const blockLevel = lineData.level
let md = ''
function finalize() {
return unified()
.use(remarkParse)
.use(remarkRehype)
.use(rehypeStringify)
.process(md)
}
async function markdownContents({ line, lineData, ended }) {
if (ended || lineData.level <= blockLevel) {
const final = String(await finalize())
return final
}
md += line.slice(blockLevel + 1) + '\n'
return markdownContents(await next())
}
return markdownContents(await next())
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
{
"name": "@terrace/block-markdown",
"type": "module",
"version": "0.0.1",
"main": "./index.js",
"scripts": {
"test": "vitest"
},
"devDependencies": {
"vitest": "^0.24.5"
},
"dependencies": {
"rehype-stringify": "^9.0.3",
"remark-parse": "^10.0.1",
"remark-rehype": "^10.1.0",
"unified": "^10.1.2"
}
}