Skip to content

Add legacy Wikidot [[note]] block parser support - #128

Open
wasd243 wants to merge 6 commits into
scpwiki:mainfrom
wasd243:feat/note
Open

Add legacy Wikidot [[note]] block parser support#128
wasd243 wants to merge 6 commits into
scpwiki:mainfrom
wasd243:feat/note

Conversation

@wasd243

@wasd243 wasd243 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What's changed

This PR adds legacy Wikidot [[note]] block grammar parsing support.

Example:

[[note]]
Note
[[/note]]

Block Rules

Based on the Wikidot DOM output of [[note]], the legacy parser renders it into HTML like:

<div class="wiki-note">
Note contents
</div>
image

The [[note]] block parser now parses it into:

<div class="wj-note">
Note contents
</div>

The [[note]] block does not have special attributes like the [[collapsible]] block (show and hide).
Also it cannot be placed inline like:

Hello[[note]]Contents[[/note]]
[[note]]Contents[[/note]]
[[note]]Contents[[/note]]Hello

It falls back to raw text. (The element that looks like an HR in the screenshot is actually an empty div class="wiki-note" rendering)
image

The empty [[note]] is allowed like:

[[note]]
[[/note]]

which will generate an empty container like:

{  
    "element": "container",  
    "data": {  
        "type": "note",  
        "attributes": {},  
        "elements": []  
    }  
}
<div class="wj-note"></div>

CSS

This PR only adds parser support. The generated HTML class is wj-note.
If the frontend already has an existing style for this block, please let me know if any changes are needed.

@wasd243
wasd243 requested a review from emmiegit as a code owner July 23, 2026 22:08
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.23%. Comparing base (c262439) to head (72af54e).
⚠️ Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
src/parsing/rule/impls/block/blocks/note.rs 93.33% 1 Missing ⚠️
src/tree/container.rs 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #128      +/-   ##
==========================================
+ Coverage   71.01%   71.23%   +0.21%     
==========================================
  Files         220      221       +1     
  Lines        6213     6260      +47     
==========================================
+ Hits         4412     4459      +47     
  Misses       1801     1801              
Flag Coverage Δ *Carryforward flag
ftml 64.39% <ø> (ø) Carriedforward from 732ba78

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
src/parsing/error.rs 42.85% <ø> (ø)
src/parsing/rule/impls/block/blocks/mod.rs 83.33% <ø> (ø)
src/parsing/rule/impls/block/mapping.rs 100.00% <ø> (+13.33%) ⬆️
src/parsing/rule/impls/block/blocks/note.rs 93.33% <93.33%> (ø)
src/tree/container.rs 50.00% <50.00%> (ø)

... and 19 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/parsing/error.rs Outdated
wasd243 and others added 2 commits July 26, 2026 20:25
Co-authored-by: Emmie <emmie.maeda@gmail.com>
@wasd243

wasd243 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

By the way, I found a weird edge case involving nested note blocks.

The current parser generates correct HTML like:

<div class="wj-note">
    <div class="wj-note">
        Contents between note blocks.
    </div>
</div>

<div class="wj-note">
    Another Content
    <div class="wj-note">
        Contents between note blocks.
    </div>
</div>

<div class="wj-note">
    Another Content
    <div class="wj-note">
        Contents between note blocks.
    </div>
    <br>
    Another Content
</div>

from the following FTML:

[!--Nested note blocks--]
[[note]]
[[note]]
[!--Empty note block--]
[[/note]]
[[/note]]

[!--Nested note blocks--]
[[note]]
[[note]]
Contents between note blocks.
[[/note]]
[[/note]]

[!--Nested note blocks--]
[[note]]
Another Content
[[note]]
Contents between note blocks.
[[/note]]
[[/note]]

[!--Nested note blocks--]
[[note]]
Another Content
[[note]]
Contents between note blocks.
[[/note]]
Another Content
[[/note]]

The legacy Wikidot parser fails on these cases and falls back to rendering the raw text instead.

image

I think it would be better to support nested note blocks instead of reproducing the legacy parser's behavior, so I didn't make the parser return an error for nested cases.

@emmiegit

Copy link
Copy Markdown
Member

By the way, I found a weird edge case involving nested note blocks.

The current parser generates correct HTML like:

<div class="wj-note">
    <div class="wj-note">
        Contents between note blocks.
    </div>
</div>

<div class="wj-note">
    Another Content
    <div class="wj-note">
        Contents between note blocks.
    </div>
</div>

<div class="wj-note">
    Another Content
    <div class="wj-note">
        Contents between note blocks.
    </div>
    <br>
    Another Content
</div>

from the following FTML:

[!--Nested note blocks--]
[[note]]
[[note]]
[!--Empty note block--]
[[/note]]
[[/note]]

[!--Nested note blocks--]
[[note]]
[[note]]
Contents between note blocks.
[[/note]]
[[/note]]

[!--Nested note blocks--]
[[note]]
Another Content
[[note]]
Contents between note blocks.
[[/note]]
[[/note]]

[!--Nested note blocks--]
[[note]]
Another Content
[[note]]
Contents between note blocks.
[[/note]]
Another Content
[[/note]]

The legacy Wikidot parser fails on these cases and falls back to rendering the raw text instead.
image

I think it would be better to support nested note blocks instead of reproducing the legacy parser's behavior, so I didn't make the parser return an error for nested cases.

Agreed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants