Skip to content

Commit

Permalink
fix: cursormagicword back to just characters.
Browse files Browse the repository at this point in the history
Tackled italic bug with removing _ from the lastword regexp.

This fixes #167.
  • Loading branch information
redimp committed Jan 31, 2025
1 parent 5b76af3 commit f930d44
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions otterwiki/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from bs4 import BeautifulSoup

# the cursor magic word which is ignored by the rendering
cursormagicword = "<!-- CuRsoRm4g1cW0Rd -->"
cursormagicword = "CuRsoRm4g1cW0Rd"

#
# patch mistune table_plugin so that not all the newlines at the end of a table are removed
Expand Down Expand Up @@ -335,7 +335,7 @@ def __init__(self, config={}):
],
env=self.env,
)
self.lastword = re.compile(r"([a-zA-Z_0-9\.]+)$")
self.lastword = re.compile(r"([a-zA-Z\-0-9\.]+)$")
self.htmlcursor = " <span id=\"otterwiki_cursor\"></span> "
# thanks to https://github.com/lepture/mistune/issues/158#issuecomment-830481284
# we can enable tables in lists
Expand Down
24 changes: 24 additions & 0 deletions tests/test_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,27 @@ def test_preview_italic_bug(create_app, req_ctx):
_A paragraph_"""
data = p.preview(content=content, cursor_line=3)
assert "<em>A paragraph</em>" in data['preview_content']
soup = bs4.BeautifulSoup(data['preview_content'], "html.parser").find("em")
assert soup
text = soup.text.strip()
assert "A paragraph" == text


def test_preview_cursor_in_codeblock(create_app, req_ctx):
from otterwiki.wiki import Page

p = Page("test")
content = """# Header
```
code in block
```
"""
data = p.preview(content=content, cursor_line=1)
print(data)
soup = bs4.BeautifulSoup(data['preview_content'], "html.parser").find(
"pre"
)
assert soup
text = soup.text.strip("`\n")
assert "code in block" == text

0 comments on commit f930d44

Please sign in to comment.