Skip to content

Commit 17279da

Browse files
authored
Fix display of bold in docs (#152)
1 parent 1ea8bec commit 17279da

5 files changed

Lines changed: 13 additions & 3 deletions

File tree

docs/_static/custom.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
span.git2cpp-bold {
2+
font-weight: bold;
3+
}

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
1212

13-
html_static_path = []
13+
html_css_files = ["custom.css"]
14+
html_static_path = ["_static"]
1415
html_theme = "sphinx_book_theme"
1516
html_theme_options = {
1617
"github_url": "https://github.com/QuantStack/git2cpp",

docs/create_markdown.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ def sanitise_line(line):
1919
line = line.replace(r"<", r"&lt;")
2020
line = line.replace(r">", r"&gt;")
2121

22+
# Replace ansi style codes with <span> elements, only bold is displayed.
23+
# Colour codes are converted to empty <span> elements to match the number of </span>.
24+
line = line.replace("\x1b[1m", r"<span class=git2cpp-bold>")
25+
line = line.replace("\x1b[0m", r"</span>")
26+
line = re.sub(r"\x1b\[[^m]+m", r"<span>", line)
27+
2228
# If there are whitespace characters at the start of the line, replace the first with an &nbsp
2329
# so that it is not discarded by the markdown parser used by the parsed-literal directive.
2430
line = re.sub(r"^\s", r"&nbsp;", line)

src/subcommand/reset_subcommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ reset_subcommand::reset_subcommand(const libgit2_object&, CLI::App& app)
2121
sub->add_flag(
2222
"--soft",
2323
m_soft_flag,
24-
"Leave your working tree files and the index unchanged. For example, if you have no staged changes, you can use"
24+
"Leave your working tree files and the index unchanged. For example, if you have no staged changes, you can use "
2525
+ ansi_code::bold + "git reset --soft HEAD~5" + ansi_code::reset + "; " + ansi_code::bold
2626
+ "git commit" + ansi_code::reset
2727
+ " to combine the last 5 commits into 1 commit. This works even with changes in the working tree, which are left untouched, but such usage can lead to confusion."

src/subcommand/stash_subcommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ stash_subcommand::stash_subcommand(const libgit2_object&, CLI::App& app)
4343
auto* pop = stash->add_subcommand(
4444
"pop",
4545
"Remove a single stashed state from the stash list and apply it on top of the current working tree state, i.e., do the inverse operation of "
46-
+ ansi_code::bold + "git stash push.\n" + ansi_code::reset
46+
+ ansi_code::bold + "git stash push" + ansi_code::reset + ".\n"
4747
);
4848
auto* apply = stash->add_subcommand(
4949
"apply",

0 commit comments

Comments
 (0)