Skip to content

[Feat] Add support for pandoc fenced divs and bracketed spans#5848

Closed
benniekiss wants to merge 6 commits into
Zettlr:developfrom
benniekiss:toolbar
Closed

[Feat] Add support for pandoc fenced divs and bracketed spans#5848
benniekiss wants to merge 6 commits into
Zettlr:developfrom
benniekiss:toolbar

Conversation

@benniekiss

@benniekiss benniekiss commented Aug 14, 2025

Copy link
Copy Markdown
Collaborator

Description

This PR adds a popover toolbar item to insert Pandoc fenced divs or bracketed spans with the configured identifier, classes, and attributes. Two tools, highlight and underline, are added to the formatting toolbar related to bracketed spans to help illustrate the functionality.

This PR implements parsing and rendering for Pandoc fenced divs and bracketed spans, and it includes several utilties and functions to make use of them.

Changes

An inline parser using delimiters was added for bracketed spans, and a composite block parser was added for fenced divs.

A renderer was added which assigns the attributes as a mark decoration.

A popover is added to the toolbar which provides three input forms to configure an identifier, classes, and attributes to assign to the fenced div or bracketed span. Fenced Divs or Bracketed Spans can be selected with the tab bar at the top of the popover, and they are inserted via the button at the bottom.

I chose the drag-handle icon since it is similar to the ::: fence syntax, but I am open to any suggestions for a different one.

The formatting toolbar was filled out with highlighting, strikethrough, and underline functions.

The highlighting format character was made configurable, so users can configure whether to use spans or == as the highlight mark.

Additional information

I was inspired by the Quarto editor's similar functionality.

The one remaining issue I have is that I can't seem to revert the background-color for the lines containing the div formatting characters. I think it's some nesting issue, but I have not found a way to fix it.

Images


Rendering:
Screenshot 2025-11-06 at 14 10 04

Hiding formatting characters:
Screenshot 2025-11-06 at 14 10 16

Inserting a div:
Screenshot 2025-11-06 at 14 12 36

The inserted div and formatting bar:
Screenshot 2025-11-06 at 14 13 03

Tested on:
macOS 15.6

@benniekiss benniekiss force-pushed the toolbar branch 2 times, most recently from 62579f0 to 38b3aca Compare August 19, 2025 18:15
@benniekiss benniekiss force-pushed the toolbar branch 3 times, most recently from 37a4e85 to 7cd6e16 Compare September 7, 2025 17:44
@benniekiss benniekiss force-pushed the toolbar branch 3 times, most recently from ff2c762 to 5a245c0 Compare November 6, 2025 17:50
@benniekiss benniekiss changed the title [Feat] Add toolbar popover for pandoc's fenced divs and bracketed spans [Feat] Add support for pandoc fenced divs and bracketed spans Nov 6, 2025
@nathanlesage

Copy link
Copy Markdown
Member

This PR is quite large, but I think I'll focus on this one next. I'll give you some time to update it, though, first :D

@benniekiss

Copy link
Copy Markdown
Collaborator Author

It really has! I'm happy to split it into two, the renderer/parser and then the UI components, but otherwise, I'll get it rebased today

@benniekiss benniekiss force-pushed the toolbar branch 2 times, most recently from ff3b184 to ae9ecca Compare November 21, 2025 21:22
@benniekiss

benniekiss commented Nov 21, 2025

Copy link
Copy Markdown
Collaborator Author

Should be pretty cleaned up at this point.

The only issue I've noticed is that in the print preview/md2html function, the closing PandocDivMark keeps being printed as a Paragraph node, and I cant track down why. The opening mark never shows, and the way the mark is registered is similar to QuoteMarks, so I would expect it not to appear. It's a lezer parsing bug, but I've submitted a patch that should fix it!

Otherwise, this has been working well for me!

@benniekiss benniekiss force-pushed the toolbar branch 4 times, most recently from 11338af to bbccf3b Compare November 28, 2025 14:44
@nathanlesage

Copy link
Copy Markdown
Member

Wonderful! I've been struggling in the past week to maybe give this PR the attention it deserves, but given that I'm still full throttle in application cycle I think to make it faster splitting it up might help so that I can give better feedback, if that works for you?

I think having this support is nice in 4.0!

@benniekiss

Copy link
Copy Markdown
Collaborator Author

That definitely works! I'll have this split into parsing/rendering and UI components sometime later today or tomorrow.

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