Skip to content

Commit

Permalink
problem: markdown doesn't look good
Browse files Browse the repository at this point in the history
  • Loading branch information
gsovereignty committed Oct 29, 2023
1 parent 6fa15bd commit 7c22566
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/lib/helpers/mundane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,27 @@ export function fetchNoteFromSet(s:Set<NDKEvent>, id:string):NDKEvent|undefined
* @return string HTML string
*/
export const makeHtml = (content: string | undefined): string => {
const converter = new showdown.Converter()
const converter = new showdown.Converter({
extensions: [...bindings]
})
content = content ?? ''

return converter.makeHtml(content)
}
}

const classMap = {
h1: 'title is-1',
h2: 'title is-2',
h3: 'title is-3',
h4: 'title is-4',
h6: 'subtitle',
ul: 'problemUL',
li: 'problemLI'
}

const bindings = Object.keys(classMap)
.map(key => ({
type: 'output',
regex: new RegExp(`<${key}(.*)>`, 'g'),
replace: `<${key} class="${classMap[key]}" $1>`
}));
12 changes: 12 additions & 0 deletions src/routes/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,15 @@
html {
overflow-x: hidden;
}

.problemUL {
list-style-position: inside;
line-height:140%;
list-style-type: square;
margin: 1%;
font-size:12pt;
}

.problemLI {
margin: 1%;
}

0 comments on commit 7c22566

Please sign in to comment.