fixed my broken merge with kurt's branch commit, updated OpenSCAD contributors
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { extractMetaData } from 'src/helpers/markdown'
|
||||
import { useMarkdownMetaData } from 'src/helpers/markdown'
|
||||
import Editor from 'rich-markdown-editor'
|
||||
import { useRef } from 'react'
|
||||
import KeyValue from 'src/components/KeyValue/KeyValue'
|
||||
|
||||
export default function EditorGuide({ content }) {
|
||||
const [rawMetadata, metadata] = extractMetaData(content)
|
||||
const [rawMetadata, metadata] = useMarkdownMetaData(content)
|
||||
|
||||
const processedContent = rawMetadata
|
||||
? content.replace(rawMetadata[0], '')
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
title: OpenSCAD
|
||||
Written with: Custom language
|
||||
Kernal type: BREP
|
||||
Maintained by: [Marius Kintel + 15 members](https://github.com/openscad)
|
||||
Maintained by: [Marius Kintel and contributors](https://github.com/openscad/openscad/graphs/contributors)
|
||||
Documentation: [openscad.org](https://openscad.org/)
|
||||
---
|
||||
OpenSCAD is a solid 3D modeler that enables the creation of parametric models using its scripting language. Models are created by utilizing a technique called constructive solid geometry. According to this technique, simple objects can be transformed and combined in order to create almost any complex model.
|
||||
@@ -1,29 +1,25 @@
|
||||
// Extracts YAML frontmatter from Markdown files
|
||||
// Gotten from this helpful comment on a react-markdown GitHub Issue: https://github.com/remarkjs/react-markdown/issues/164#issuecomment-890497653
|
||||
export function useMarkdownMetaData(text: string): Array<any> {
|
||||
const metaData = {} as any
|
||||
return React.useMemo(() => {
|
||||
const metaData = {} as any
|
||||
/* ... */
|
||||
const metaRegExp = RegExp(/^---[\r\n](((?!---).|[\r\n])*)[\r\n]---$/m) as any
|
||||
// get metadata
|
||||
const rawMetaData = metaRegExp.exec(text)
|
||||
|
||||
let keyValues
|
||||
|
||||
if (rawMetaData !== null) {
|
||||
// rawMeta[1] are the stuff between "---"
|
||||
keyValues = rawMetaData[1].split('\n')
|
||||
|
||||
// which returns a list of key values: ["key1: value", "key2: value"]
|
||||
keyValues.forEach((keyValue) => {
|
||||
// split each keyValue to keys and values
|
||||
const [, key, value] = keyValue.split(/(.+): (.+)/)
|
||||
metaData[key] = value.trim()
|
||||
})
|
||||
}
|
||||
return [rawMetaData, metaData]
|
||||
}, [text])
|
||||
}
|
||||
|
||||
const metaRegExp = RegExp(/^---[\r\n](((?!---).|[\r\n])*)[\r\n]---$/m)
|
||||
// get metadata
|
||||
const rawMetaData = metaRegExp.exec(text)
|
||||
|
||||
let keyValues
|
||||
|
||||
if (rawMetaData!) {
|
||||
// rawMeta[1] are the stuff between "---"
|
||||
keyValues = rawMetaData[1].split('\n')
|
||||
|
||||
// which returns a list of key values: ["key1: value", "key2: value"]
|
||||
keyValues.forEach((keyValue) => {
|
||||
// split each keyValue to keys and values
|
||||
const [, key, value] = keyValue.split(/(.+): (.+)/)
|
||||
metaData[key] = value.trim()
|
||||
})
|
||||
}
|
||||
return [rawMetaData, metaData]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user