Skip to content

Commit

Permalink
Merge pull request #256 from ematipico/fix/emit-correct-heading
Browse files Browse the repository at this point in the history
fix: emit a level 2 heading for sub commands in markdown
  • Loading branch information
pacak authored Aug 1, 2023
2 parents b89ede5 + 9c3f15e commit af3c7cc
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 af3c7cc

Please sign in to comment.