-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* scaffold markdown modification * Testing markdown * Double curly braces markdown * Lint + hacky solution to the single surly braces * fix single-curly markdown links * Typo * Hardcoded S/P/T for easier reading * Added markdown button to preview * Update packages/viewer/src/components/Shared/SeMarkdown.svelte * Renamed SeMarkdown to ExtMarkdown, edited the preview --------- Co-authored-by: abram! <[email protected]>
- Loading branch information
1 parent
7c3939f
commit de042c8
Showing
3 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script lang="ts"> | ||
import { Ref } from '@pi-base/core' | ||
export let source: string | ||
const modify = (s: string) => { | ||
const singlecurly = /{(?<type>[SPT])(?<id>\d+)}/g | ||
const doublecurlies = /{{(?<prefix>\w+):(?<id>[^{]+)}}/g | ||
// Replace double curly braces | ||
s = s.replace(doublecurlies, (_, prefix, id) => { | ||
// Perform replacement based on prefix and id | ||
const ref = Ref.format({ | ||
kind: prefix, | ||
id: id, | ||
}) | ||
return `[${ref.title}](${ref.href})` | ||
}) | ||
// Replace single curly braces | ||
s = s.replace(singlecurly, (_, type, id) => { | ||
// Perform replacement based on type and id | ||
if (type === 'S') { | ||
return `[S${id}](https://topology.pi-base.org/spaces/S${id})` | ||
} else if (type === 'P') { | ||
return `[P${id}](https://topology.pi-base.org/properties/P${id})` | ||
} else { | ||
return `[T${id}](https://topology.pi-base.org/theorems/T${id})` | ||
} | ||
}) | ||
return s | ||
} | ||
</script> | ||
|
||
<h4>External Markdown</h4> | ||
<pre> | ||
{modify(source)} | ||
</pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters