Skip to content

Commit

Permalink
MD_HARD_WRAP option to allow differences in opinion about line breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
irskep committed Jul 21, 2024
1 parent ed43f5e commit 07dc7a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ docs, but these are some you might care to know about:
(and write it to a file in `INSTANCE_PATH`) if one doesn't exist.
* `SILICON_EDITOR`: When set to `textarea`, this disables the CodeMirror text
editor when editing pages and uses a standard textarea element instead.
* `MD_HARD_WRAP`: When set to `true`, all line breaks are converted to `<br>`
tags. By default, you must suffix a line with two spaces (` `) to get a
`<br>`.

To initialize the database after the configuration settings have been set,
run the following command. It will create an `instance` directory in the root
Expand Down
2 changes: 2 additions & 0 deletions silicon/render_md.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from flask import url_for
from mistune import create_markdown, HTMLRenderer
from mistune.util import safe_entity
Expand Down Expand Up @@ -111,6 +112,7 @@ def md_renderer(text):
"""Render a Markdown document into HTML."""

markdown = create_markdown(
hard_wrap=(os.getenv('MD_HARD_WRAP') or "").lower() == "true",
renderer=CustomRenderer(escape=False),
plugins=[
'strikethrough',
Expand Down

0 comments on commit 07dc7a8

Please sign in to comment.