Skip to content

Commit

Permalink
fix: emit a level 2 heading in markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Aug 1, 2023
1 parent b89ede5 commit 9c3f15e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/buffer/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ impl Doc {
let mut mono = 0;
let mut def_list = false;
let mut code_block = false;
let mut app_name_seen = false;
for (ix, token) in self.tokens.iter().copied().enumerate() {
match token {
Token::Text { bytes, style } => {
Expand Down Expand Up @@ -384,7 +385,12 @@ impl Doc {
match b {
Block::Header => {
blank_markdown_line(&mut res);
res.push_str("# ");
if app_name_seen {
res.push_str("## ");
} else {
res.push_str("# ");
app_name_seen = true
}
}
Block::Section2 => {
res.push_str("");
Expand Down
6 changes: 3 additions & 3 deletions tests/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn nested() {
* [`options alpha`↴](#options-alpha)
* [`options beta`↴](#options-beta)
# options
## options
Options
Expand All @@ -91,7 +91,7 @@ Options
- **`beta`** — \n Beta
# options alpha
## options alpha
Alpha
Expand All @@ -100,7 +100,7 @@ Alpha
- **`-h`**, **`--help`** — \n Prints help information
# options beta
## options beta
Beta
Expand Down

0 comments on commit 9c3f15e

Please sign in to comment.