homebrewery icon indicating copy to clipboard operation
homebrewery copied to clipboard

[Editor] Change folded code text generation

Open G-Ambatte opened this issue 2 years ago • 1 comments

This PR will resolve #1907.

This PR modifies the text generated when code is folded, using the following rules:

  1. Use the first header in the folded section. At this point, a h6 at the top of the fold will be used over a later h1.
  2. If no headers exist, use the text of the first non-empty line.
  3. If no non-empty lines exist, generate text "Lines {start line}-{end line}"

Example output:

Folded: image

Brew Source:

# Combat Maneuvers
\page
# Combat Actions
\page
## Movement
\page
## Defense
\page
## Special Targeting
\page
# Footnotes on source rules
\page
### Parry Defence
\page
## Other options/wrinkles
\page
### Weapon Length and Positioning
\page
## Damage-type Maneuvers
\page
## No Quarter <small>Combat manuevers - for fighting</small>
\page





\page

This is a test page.
This is the second line.

\page

This is a test page.
This is the second line.

### Header later on


\page

G-Ambatte avatar Sep 25 '22 01:09 G-Ambatte

As per the comments on #1907, I've added a color attribute to the LESS for the fold-marker, changing it from blue to grey.

In this example, I've folded all of the code, then re-opened one to make sure that the heading (and it's color) is visible.

image

G-Ambatte avatar Sep 25 '22 07:09 G-Ambatte

This seems fine to me now. Any objection to merging @G-Ambatte ?

calculuschild avatar Sep 26 '22 19:09 calculuschild

I've converted to an actual PR instead of a Draft, so it should be ready to merge!

G-Ambatte avatar Sep 26 '22 20:09 G-Ambatte

:cook: 🤌

calculuschild avatar Sep 26 '22 20:09 calculuschild