diff --git a/peg-highlight/pmh_styleparser.c b/peg-highlight/pmh_styleparser.c index 4c577c90..ae4fd4c5 100644 --- a/peg-highlight/pmh_styleparser.c +++ b/peg-highlight/pmh_styleparser.c @@ -212,6 +212,7 @@ static pmh_attr_font_styles *new_font_styles() ret->italic = false; ret->bold = false; ret->underlined = false; + ret->strikeout = false; return ret; } @@ -375,7 +376,7 @@ static pmh_style_attribute *interpret_attributes(style_parser_data *p_data, raw_attribute *raw_attributes) { pmh_style_attribute *attrs = NULL; - + raw_attribute *cur = raw_attributes; while (cur != NULL) { @@ -383,7 +384,7 @@ static pmh_style_attribute *interpret_attributes(style_parser_data *p_data, pmh_style_attribute *attr = new_attr(cur->name, atype); attr->lang_element_type = lang_element_type; attr->value = new_attr_value(); - + if (atype == pmh_attr_type_foreground_color || atype == pmh_attr_type_background_color || atype == pmh_attr_type_caret_color @@ -402,9 +403,9 @@ static pmh_style_attribute *interpret_attributes(style_parser_data *p_data, { pmh_attr_font_size *fs = new_font_size(); attr->value->font_size = fs; - + char *trimmed_value = trim_str_dup(cur->value); - + fs->is_relative = (*trimmed_value == '+' || *trimmed_value == '-'); char *endptr = NULL; fs->size_pt = (int)strtol(cur->value, &endptr, 10); @@ -415,7 +416,7 @@ static pmh_style_attribute *interpret_attributes(style_parser_data *p_data, free_style_attributes(attr); attr = NULL; } - + free(trimmed_value); } else if (atype == pmh_attr_type_font_family) @@ -430,19 +431,21 @@ static pmh_style_attribute *interpret_attributes(style_parser_data *p_data, while (value_cur != NULL) { char *standardized_value = standardize_str(value_cur->value); - + if (EQUALS(standardized_value, "italic")) attr->value->font_styles->italic = true; else if (EQUALS(standardized_value, "bold")) attr->value->font_styles->bold = true; else if (EQUALS(standardized_value, "underlined")) attr->value->font_styles->underlined = true; + else if (EQUALS(standardized_value, "strikeout")) + attr->value->font_styles->strikeout = true; else { report_error(p_data, cur->line_number, "Value '%s' is invalid for attribute '%s'", standardized_value, cur->name); } - + free(standardized_value); value_cur = value_cur->next; } @@ -452,16 +455,16 @@ static pmh_style_attribute *interpret_attributes(style_parser_data *p_data, { attr->value->string = trim_str_dup(cur->value); } - + if (attr != NULL) { // add to linked list attr->next = attrs; attrs = attr; } - + cur = cur->next; } - + return attrs; } diff --git a/peg-highlight/pmh_styleparser.h b/peg-highlight/pmh_styleparser.h index 96afe3c1..7b9d1baa 100644 --- a/peg-highlight/pmh_styleparser.h +++ b/peg-highlight/pmh_styleparser.h @@ -33,6 +33,7 @@ typedef struct bool italic; bool bold; bool underlined; + bool strikeout; } pmh_attr_font_styles; /** \brief Font size attribute value. */ diff --git a/src/hgmarkdownhighlighter.cpp b/src/hgmarkdownhighlighter.cpp index a98f219a..14291148 100644 --- a/src/hgmarkdownhighlighter.cpp +++ b/src/hgmarkdownhighlighter.cpp @@ -811,7 +811,7 @@ void HGMarkdownHighlighter::parseInternal() memcpy(content, data, len); content[len] = '\0'; - pmh_markdown_to_elements(content, pmh_EXT_NONE, &result); + pmh_markdown_to_elements(content, pmh_EXT_STRIKE, &result); } void HGMarkdownHighlighter::handleContentChange(int /* position */, int charsRemoved, int charsAdded) diff --git a/src/resources/themes/v_moonlight/v_moonlight.mdhl b/src/resources/themes/v_moonlight/v_moonlight.mdhl index 5bee2811..bfaf0d53 100644 --- a/src/resources/themes/v_moonlight/v_moonlight.mdhl +++ b/src/resources/themes/v_moonlight/v_moonlight.mdhl @@ -130,7 +130,7 @@ foreground: 5c6370 VERBATIM foreground: 98c379 font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New -# [VNote] Codeblock sylte from HighlightJS (bold, italic, underlined, color) +# [VNote] Codeblock sylte from HighlightJS (bold, italic, underlined, strikeout, color) # The last occurence of the same attribute takes effect # Could specify multiple attribute in one line hljs-comment: 5c6370 @@ -172,4 +172,5 @@ BLOCKQUOTE foreground: 5c6370 STRIKE -strike-color: 586e75 +foreground: e57373 +font-style: strikeout diff --git a/src/resources/themes/v_native/v_native.mdhl b/src/resources/themes/v_native/v_native.mdhl index 93a50332..72b4cd40 100644 --- a/src/resources/themes/v_native/v_native.mdhl +++ b/src/resources/themes/v_native/v_native.mdhl @@ -129,7 +129,7 @@ foreground: 93a1a1 VERBATIM foreground: 673ab7 font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New -# [VNote] Codeblock sylte from HighlightJS (bold, italic, underlined, color) +# [VNote] Codeblock sylte from HighlightJS (bold, italic, underlined, strikeout, color) # The last occurence of the same attribute takes effect hljs-comment: 6c6c6c hljs-keyword: 0000ee @@ -170,4 +170,5 @@ BLOCKQUOTE foreground: 00af00 STRIKE -strike-color: 586e75 +foreground: b71c1c +font-style: strikeout diff --git a/src/resources/themes/v_pure/v_pure.mdhl b/src/resources/themes/v_pure/v_pure.mdhl index 402b27ea..812de59c 100644 --- a/src/resources/themes/v_pure/v_pure.mdhl +++ b/src/resources/themes/v_pure/v_pure.mdhl @@ -130,7 +130,7 @@ foreground: 93a1a1 VERBATIM foreground: 673ab7 font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New -# [VNote] Codeblock sylte from HighlightJS (bold, italic, underlined, color) +# [VNote] Codeblock sylte from HighlightJS (bold, italic, underlined, strikeout, color) # The last occurence of the same attribute takes effect # Could specify multiple attribute in one line hljs-comment: 6c6c6c @@ -171,4 +171,5 @@ BLOCKQUOTE foreground: 00af00 STRIKE -strike-color: 586e75 +foreground: b71c1c +font-style: strikeout diff --git a/src/vstyleparser.cpp b/src/vstyleparser.cpp index c442a694..4ea3c9cc 100644 --- a/src/vstyleparser.cpp +++ b/src/vstyleparser.cpp @@ -88,12 +88,19 @@ QTextCharFormat VStyleParser::QTextCharFormatFromAttrs(pmh_style_attribute *attr if (fontStyle->italic) { format.setFontItalic(true); } + if (fontStyle->bold) { format.setFontWeight(QFont::Bold); } + if (fontStyle->underlined) { format.setFontUnderline(true); } + + if (fontStyle->strikeout) { + format.setFontStrikeOut(true); + } + break; } @@ -159,6 +166,8 @@ QHash VStyleParser::fetchCodeBlockStyles(const QFont & format.setFontItalic(true); } else if (val == "underlined") { format.setFontUnderline(true); + } else if (val == "strikeout") { + format.setFontStrikeOut(true); } else { // Treat it as the color RGB value string without '#'. QColor color("#" + val);