-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(gnoweb): Add column extension #3763
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: gfanton <[email protected]>
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Signed-off-by: gfanton <[email protected]>
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
Let's go ❤️ |
Signed-off-by: gfanton <[email protected]>
Signed-off-by: gfanton <[email protected]>
Signed-off-by: gfanton <[email protected]>
Signed-off-by: gfanton <[email protected]>
@aeddi Yeah I agree regarding the readability but after some discussion in the dedicated issue, it seems people preferred the writing simplicity coupled with an opinionated gnoweb rendering based on headings (not images). To get the images, the hack is to create an empty heading. Please note that |
@alexiscolin Ok got it 👍 |
There is one last edge case that I’m unsure how to handle: <gno-columns>
content 1
content 2
## Title 1
content 3
## Title 2
content 4
</gno-columns> In this scenario, there is intermediary content between the opening tag and the first heading. Therefore, I suggest that we always create a first column, regardless of whether a heading is present. |
After some time to think about this, and considering that this edge case occurs because the first encountered title following the opening tag |
Signed-off-by: gfanton <[email protected]>
Signed-off-by: gfanton <[email protected]>
Signed-off-by: gfanton <[email protected]>
Signed-off-by: gfanton <[email protected]>
Signed-off-by: gfanton <[email protected]>
Signed-off-by: gfanton <[email protected]>
@leohhhn where should we document this feature ? |
Related to this, yesterday, @jeronimoalbi asked for a place where all the Markdown extensions would be displayed. I mentioned |
Let's start by creating a realm in the Some realms/packages that use the html columns are We can add a showcase to |
Ok, so after discussing it with @alexiscolin and thinking about the edge case, I've got two points I would like to discuss before potentially implementing them myself if needed and if @gfanton agrees. Nested tagsThe first point concerns the case of an input containing Input<gno-columns>
## title 1
content 1
<gno-columns>
## title 2
content 2
## title 3
content 3
</gno-columns>
## title 4
content
</gno-columns> Instead of producing an output that tries to "guess" which opening/closing tags should be ignored based on nesting depth, I'm suggesting we do something simpler, with less intelligence, and less likely to cause issues IMO. Current output<div class="gno-cols">
<!-- Column 1 -->
<div>
<h2>title 1</h2>
<p>content 1</p>
</div>
<!-- Column 2 -->
<div>
<h2>title 2</h2>
<p>content 2</p>
</div>
<!-- Column 3 -->
<div>
<h2>title 3</h2>
<p>content 3</p>
</div>
<!-- Column 4 -->
<div>
<h2>title 4</h2>
<p>content 4</p>
</div>
</div> Option AThe first option would simply be to have a if isTagOpened && currentToken == openingTag {
return // Just ignore this invalid opening tag.
}
if !isTagOpened && currentToken == closingTag {
return // Just ignore this invalid closing tag.
} So the input above would then be processed as follows by the parser. Input<gno-columns> <- Open
## title 1
content 1
<gno-columns> <- Ignore this invalid opening tag
## title 2
content 2
## title 3
content 3
</gno-columns> <- Close
## title 4
content
</gno-columns> <- Ignore this invalid closing tag And should produce the following output. Output<div class="gno-cols">
<!-- Column 1 -->
<div>
<h2>title 1</h2>
<p>content 1</p>
</div>
<!-- Column 2 -->
<div>
<h2>title 2</h2>
<p>content 2</p>
</div>
<!-- Column 3 -->
<div>
<h2>title 3</h2>
<p>content 3</p>
</div>
</div>
<h2>title 4</h2>
<p>content 4</p> Option BI looked for a standard behavior to apply by trying to nest identical tags that shouldn't be nested in HTML. The problem is that most HTML tags nest within themselves just fine. I had the idea to test it with elements like So the behavior is as follows (tested on Firefox and Brave): if isTagOpened && currentToken == openingTag {
closePrevColumn() // Automatically close the previous tag if a new opening one is read
openNewColumn()
}
if !isTagOpened && currentToken == closingTag {
return // Just ignore this invalid closing tag.
} So the input above would then be processed as follows by the parser. Input<gno-columns> <- Open 1
## title 1
content 1
<!-- </gno-columns> --> <- Automatically close 1 before opening 2
<gno-columns> <- Open 2
## title 2
content 2
## title 3
content 3
</gno-columns> <- Close 2
## title 4
content
</gno-columns> <- Ignore this invalid closing tag And should produce the following output. Output<div class="gno-cols">
<!-- Column 1 -->
<div>
<h2>title 1</h2>
<p>content 1</p>
</div>
</div>
<div class="gno-cols">
<!-- Column 1 -->
<div>
<h2>title 2</h2>
<p>content 2</p>
</div>
<!-- Column 2 -->
<div>
<h2>title 3</h2>
<p>content 3</p>
</div>
</div>
<h2>title 4</h2>
<p>content 4</p> Column not starting with a headingFor me, the ideal would be to have separators to make the division of column content explicit and easily readable by both humans and the parser. But sticking to the current system, consider an input with an opening tag not immediately followed by a heading. Input<gno-columns>
content 1
content 2
## Title 1
content 3
## Title 2
content 4
</gno-columns> Currently, we produce an "invalid" column with the first lines, then we use the first heading we parse as a reference for defining subsequent columns. Output<div class="gno-cols">
<!-- Column 1 -->
<div>
<p>content 1</p>
<p>content 2</p>
</div>
<!-- Column 2 -->
<div>
<h2>title 1</h2>
<p>content 3</p>
</div>
<!-- Column 3 -->
<div>
<h2>title 2</h2>
<p>content 4</p>
</div>
</div> Option AWe simply ignore the opening tag if it's not followed by a heading, and then we skip the closing tag since there wasn't a valid opening tag. So the input above would then be processed as follows by the parser. Input<gno-columns> <- Ignore this invalid opening tag (not followed by a heading)
content 1
content 2
## Title 1
content 3
## Title 2
content 4
</gno-columns> <- Ignore this invalid closing tag (no previous valid opening tag) And should produce the following output. Output<p>content 1</p>
<p>content 2</p>
<h2>title 1</h2>
<p>content 3</p>
<h2>title 2</h2>
<p>content 4</p> Option BWe put everything between So the input above would then be processed as follows by the parser. Input<gno-columns> <- Open
content 1
content 2
## Title 1
content 3
## Title 2
content 4
</gno-columns> <- Close And should produce the following output. Output<div class="gno-cols">
<!-- Column 1 -->
<p>content 1</p>
<p>content 2</p>
<h2>title 1</h2>
<p>content 3</p>
<h2>title 2</h2>
<p>content 4</p>
</div> Personally, in both cases I prefer option A, which basically means: "If the current tag is invalid, then just ignore it", which seems much clean and safe to me. |
@aeddi thanks for the feedback, this is really pertinent, and I think you right, we should avoid putting too much inteligence in this and keep thing simple.
Optiona A: I think this is the correct behavior; removing depth simplifies the logic and still makes things pretty intuitive in terms of results.
You might be right with option A, but I'm not sure. I don't feel this is intuitive and might even be confusing. Ignoring the whole tag because of intermediary content might be too a bit too aggressive for me as the column are totally ignored . Also, you need to parse the next slibbing (not parse the next line), which may require some backtracking. Options CWdyt about skipping content until finding a heading? and probably putting the content outside the cols. Output<p>content 1</p>
<p>content 2</p>
<div class="gno-cols">
<!-- Column 1 -->
<div>
<h2>title 1</h2>
<p>content 3</p>
</div>
<!-- Column 2 -->
<div>
<h2>title 2</h2>
<p>content 4</p>
</div>
</div> In both case i don't like Option B |
I agree that option C clearly seems better than B. Option A is indeed more radical than B, but I think it might be the right approach. In blunt terms: "if it's invalid, we just consider it doesn't exist." BTW, maybe we should display a warning message above the rendering of a Realm on gnoweb to indicate to the user that something is wrong? Like a summary/detail tag that indicates something is wrong with this rendering, followed by a list of warnings such as unexpected 'gno-column' closing tag at line 37. But this is out of the scope of this PR anyway. Honestly, option C works for me as well, so I'll let you decide. |
Guys, for a few examples of what people might do, check out the realms that I listed above |
Addresses #3255
This PR implements column extension into
gnoweb
following this format:Notes
testdatas
files for example of input/output/r/demo/mardown_test
that need to be improved with usage, example and description (cc @leohhhn)Preview
example output code
example with images (empty heading)
TODO