Skip to content

Commit

Permalink
Command 'parse_gmd': Allow up to 2 spaces in highlighted expression b…
Browse files Browse the repository at this point in the history
…etween single quotes.
  • Loading branch information
dtschump committed Jun 10, 2024
1 parent 5939246 commit 8bc7efd
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/gmic_stdlib.gmic
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,7 @@ clean_cluts :
#@cli : Compress each of the selected images into a set of keypoints that can be further decompressed \
# using command ''decompress_from_keypoints''.
#@cli : **Beware**: This type of compression is effective only for images with very smooth content.
#@cli : 'method' can be { 0:PDE | 1:RBF }. Add '2' to 'method' to enable removal step.
#@cli : 'method' can be { 0:PDE | 1:RBF }. Add '2' to 'method' to skip the point removal step.
#@cli : - 'max_keypoints' is the maximal number of keypoints generated by the compression method. \
# If 'max_keypoints<0', the removal step is not done when number of maximal keypoints has been reached. \
# 'max_keypoints=0' means 'no limits'.
Expand Down Expand Up @@ -6882,8 +6882,9 @@ parse_gmd :
section = subsection = subsubsection = subsubsubsection = anchor =
bullet = subbullet = subsubbullet = center = right = table = blockquote = detail_block = code_block =
shell = bold_italic_a = bold_italic_u = bold_a = bold_u = italic_a = italic_u = strikethrough = underline =
monospace = value_set = word_highlight = url = page_link = text_link1 = text_link2 = img1 = img2 = pipeline =
monospace = value_set = expr_highlight = url = page_link = text_link1 = text_link2 = img1 = img2 = pipeline =
formula = opening_offset = -1;
expr_highlight_whitespaces = 0;

blank(c) = isin(c,_' ',_'\n',s_whitespace,s_tab,0);
semiblank(c) = isin(c,_' ',_'\n',_'.',_',',_';',_':',_'!',_'?',
Expand Down Expand Up @@ -7238,16 +7239,17 @@ parse_gmd :
res[y] = e_value_set;
):

# Word highlight: ' 'word_highlight' '.
# Expression highlight: ' 'expr_highlight' '.
non_escaped && c==_'\'' && nc!=c?(
word_highlight<0 && semiblank(pc)?( # Opening
word_highlight = y;
expr_highlight<0 && semiblank(pc)?( # Opening
expr_highlight = y;
expr_highlight_whitespaces = 0;
):
word_highlight>=0 && y>word_highlight + 1 && semiblank(nc)?( # Closing
opening_offset = word_highlight;
res[word_highlight++] = s_word_highlight;
copy(res[word_highlight],i[word_highlight],y - word_highlight); # Cancel tokens found inside
res[y] = e_word_highlight;
expr_highlight>=0 && y>expr_highlight + 1 && semiblank(nc)?( # Closing
opening_offset = expr_highlight;
res[expr_highlight++] = s_expr_highlight;
copy(res[expr_highlight],i[expr_highlight],y - expr_highlight); # Cancel tokens found inside
res[y] = e_expr_highlight;
);
):

Expand Down Expand Up @@ -7355,7 +7357,7 @@ parse_gmd :
);

# Reset tokens that cannot contain whitespace.
reset(word_highlight);
(++expr_highlight_whitespaces)>2?reset(expr_highlight);
reset(url);
text_link2>=0?(reset(text_link1); reset(text_link2));
img2>=0?(reset(img1); reset(img2));
Expand Down Expand Up @@ -7384,7 +7386,7 @@ parse_gmd :
reset(strikethrough);
reset(underline);
reset(monospace);
reset(word_highlight);
reset(expr_highlight);
reset(url);
reset(page_link);
text_link2>=0?(reset(text_link1); reset(text_link2));
Expand Down Expand Up @@ -7419,7 +7421,7 @@ parse_gmd :
underline>=opening_offset ? reset(underline);
monospace>=opening_offset ? reset(monospace);
value_set>=opening_offset ? reset(value_set);
word_highlight>=opening_offset ? reset(word_highlight);
expr_highlight>=opening_offset ? reset(expr_highlight);
url>=opening_offset ? reset(url);
page_link>=opening_offset ? reset(page_link);
text_link1>=opening_offset || text_link2>=opening_offset ? (reset(text_link1); reset(text_link2));
Expand Down Expand Up @@ -7461,7 +7463,7 @@ gmd2html : skip "${1=}"
write(c);
):(
isin(c,e_bold_a,e_bold_u,e_bold_italic_a,e_bold_italic_u,e_italic_a,e_italic_u,
e_monospace,e_strikethrough,e_underline,e_word_highlight) ? write('</span>'):
e_monospace,e_strikethrough,e_underline,e_expr_highlight) ? write('</span>'):
isin(c,e_bullet,e_subbullet,e_subsubbullet) ? write('</div>\n'):
c==e_section ? write('</h2>\n'):
c==e_subsection ? write('</h3>\n'):
Expand Down Expand Up @@ -7582,7 +7584,7 @@ gmd2html : skip "${1=}"
c==s_monospace ? write('<span class=\"gmd_monospace\">'):
c==s_value_set ? write('<span class=\"gmd_value_set\">{'):
c==e_value_set ? write('}</span>'):
c==s_word_highlight ? write('<span class=\"gmd_word_highlight\">'):
c==s_expr_highlight ? write('<span class=\"gmd_expr_highlight\">'):

c==s_url ? (
ind_e = find(#1,e_url,y);
Expand Down Expand Up @@ -7970,8 +7972,8 @@ gmd2ascii :
c==e_monospace ? write([vt100_n,_'\47']):
c==s_value_set ? write([vt100_g,vt100_i,_'{']):
c==e_value_set ? write([_'}',vt100_n]):
c==s_word_highlight ? write([_'\47',vt100_g]):
c==e_word_highlight ? write([vt100_n,_'\47']):
c==s_expr_highlight ? write([_'\47',vt100_g]):
c==e_expr_highlight ? write([vt100_n,_'\47']):

isin(c,s_url,s_page_link,s_text_link) ? write(vt100_u):
c==m_text_link ? (
Expand Down Expand Up @@ -8106,8 +8108,8 @@ _gmd_tokens :
const e_monospace = -54;
const s_value_set = -55;
const e_value_set = -56;
const s_word_highlight = -57;
const e_word_highlight = -58;
const s_expr_highlight = -57;
const e_expr_highlight = -58;

const s_url = -59;
const e_url = -60;
Expand Down

0 comments on commit 8bc7efd

Please sign in to comment.