A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/django-wiki/django-wiki/issues/1246 below:

Edit section fails when fenced code block contains comments · Issue #1246 · django-wiki/django-wiki · GitHub

Discussed in #1245

Originally posted by chrisv2 January 8, 2023
The following markup will break section editing (due to the # in the fenced code block):

# Section 1
Section 1 Lorem ipsum dolor sit amet

```python
# hello world
print("hello world")
```

# Section 2
Section 2 Lorem ipsum dolor sit amet
Expected result

When clicking the "edit" link next to "Section 2", the editor should show the following markup:

# Section 2
Section 2 Lorem ipsum dolor sit amet
Actual result

The editor shows parts of the fenced code block:

# hello world
print("hello world")
```

# Section 2
Section 2 Lorem ipsum dolor sit amet
Notes

Actually it is surprisingly hard to create a proper fix for that, as it is not possible to get source line numbers from the markdown parser. Currently, the editsection plugin parses the source itself by using regexes, but that doesn't account for fenced code blocks, and it's probably quite difficult to do this with regex alone. IMHO we could do one of the following:

  1. loop over markdown source line by line, detecting headers and start/end of fenced code blocks (and possibly other blocks like HTML)
  2. create a block level extension and annotate each h[1-6] with the source line, then find them in the markup

I'm interested in hacking at this, but I'm not sure which is the best approach. Any thoughts?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4