From 74d6e788c9430521c96ede21557a9a32bbd76a34 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Thu, 1 Jul 2021 13:28:57 +0000 Subject: add awful realization of formatting alternate fonts Why is it awful? Because a lot of code is duplicated. And the code is badly designed. As a result, we have one bug, which i don't know how to fix (if you know - write me at email): .BI [ "--init, -i"] ^ start italic font style ^ must start bold, but still using italic But I couldn't leave it as it is and have made a dirty trick: ` - match: '"[^\s]' scope: invalid.illegal pop: true` ` If the '"', which is supposed to end the string, has a not white-space as following character, then I scoping it like illegal syntax. Anyway, it's not correct to write this way, put a white-space after '"' :) --- man.sublime-syntax | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/man.sublime-syntax b/man.sublime-syntax index 4f1dadd..1decbe2 100644 --- a/man.sublime-syntax +++ b/man.sublime-syntax @@ -43,6 +43,14 @@ contexts: push: macros_line pop: true + - match: '{{cc}}(?={{font_alt}})\b' + scope: keyword.control.man + push: font_alts + with_prototype: + - match: '(?={{escape}}|$)' + pop: true + pop: true + - match: '{{cc}}(?={{font_style}})\b' scope: keyword.control.man push: font_styles @@ -78,6 +86,113 @@ contexts: pop: true + font_alts: + - match: \bB + scope: keyword.control.man + push: font_alt_bold + - match: \bR + scope: keyword.control.man + push: font_alt_regular + - match: \bI + scope: keyword.control.man + push: font_alt_italic + + + font_alt_bold: + - match: I\s+ + scope: keyword.control.man + push: + - meta_content_scope: markup.bold.man + - include: start_and_end_string + + - match: '\s+' + push: + - meta_content_scope: markup.italic.man + - clear_scopes: 1 + - include: font_alt_odd_pop + + - match: R\s+ + scope: keyword.control.man + push: + - meta_content_scope: markup.bold.man + - include: start_and_end_string + + - match: '\s+' + push: + - meta_content_scope: markup.regular.man + - clear_scopes: 1 + - include: font_alt_odd_pop + + + font_alt_regular: + - match: B\s+ + scope: keyword.control.man + push: + - meta_content_scope: markup.regular.man + - include: start_and_end_string + + - match: '\s+' + push: + - meta_content_scope: markup.bold.man + - clear_scopes: 1 + - include: font_alt_odd_pop + + - match: I\s+ + scope: keyword.control.man + push: + - meta_content_scope: markup.regular.man + - include: start_and_end_string + + - match: '\s+' + push: + - meta_content_scope: markup.italic.man + - clear_scopes: 1 + - include: font_alt_odd_pop + + + font_alt_italic: + - match: B\s+ + scope: keyword.control.man + push: + - meta_content_scope: markup.italic.man + - include: start_and_end_string + + - match: '\s+' + push: + - meta_content_scope: markup.bold.man + - clear_scopes: 1 + - include: font_alt_odd_pop + + - match: R\s+ + scope: keyword.control.man + push: + - meta_content_scope: markup.italic.man + - include: start_and_end_string + + - match: '\s+' + push: + - meta_content_scope: markup.regular.man + - clear_scopes: 1 + - include: font_alt_odd_pop + + + start_and_end_string: + - match: '(?<=\s)"' + push: + - match: '"[^\s]' + scope: invalid.illegal + pop: true + - match: '"' + pop: true + + + font_alt_odd_pop: + - include: start_and_end_string + + - match: '\s+' + pop: true + + font_styles: - match: (B\b|{{escape}}(B)) captures: -- cgit v1.2.3-18-g5258