Skip to content

Commit

Permalink
Fixes text parsing within links
Browse files Browse the repository at this point in the history
  • Loading branch information
JujuAdams committed Jan 29, 2023
1 parent 8bde820 commit d73f962
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
21 changes: 5 additions & 16 deletions objects/obj_test_markdown/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,15 @@ text += "## Header 2\n";
text += "### Header 3\n";
text += "- Lorem Ipsum is simply *dummy text* of the printing and **typesetting**_industry.\n";
text += "1. _**Lorem Ipsum**_ has been the industry's \\*standard dummy\\* text ever since ***the 1500s***\n";
text += "2. [An unknown printer](url) took a galley of type and scrambled it to make a type specimen book.\n";
text += "2. [![spr_white_coin] An unknown printer](url) took a galley of type and scrambled it to make a type specimen book.\n";
text += "> It has survived not only five centuries, but also the leap into electronic typesetting, remaining [spr_coin] [rainbow]essentially unchanged[/rainbow] ![spr_coin].\n";

//scribble_markdown_set_styles({
// body: {
// font: "fnt_style",
// },
// header1: {
// font: "fnt_style_header1",
// },
// header2: {
// font: "fnt_style_header2",
// },
// header3: {
// font: "fnt_style_header3",
// },
// bullet_sprite: spr_coin,
//});
scribble_markdown_set_styles({
bullet_sprite: spr_coin,
});

text = scribble_markdown_format(text);
show_message(text);

element = scribble(text)
.align(fa_left, fa_middle)
Expand Down
22 changes: 16 additions & 6 deletions scripts/scribble_markdown_format/scribble_markdown_format.gml
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ function scribble_markdown_format(_string)
}
else
{
if (_value == ord("[")) //Links
if (!_in_link && (_value == ord("["))) //Links
{
#region [text](region)

Expand All @@ -506,16 +506,26 @@ function scribble_markdown_format(_string)
else if (_link_next_value == ord("]"))
{
++_link_peek;
if (buffer_peek(_buffer, _link_peek, buffer_u8) == ord("(")) _is_link = true;
break;

if (buffer_peek(_buffer, _link_peek, buffer_u8) == ord("("))
{
_is_link = true;
break;
}

++_link_size;
}
else
{
++_link_size;
++_link_peek;
}

++_link_size;
++_link_peek;
}

if (_is_link)
{
_is_link = false;

//Look for the name of the region (which would otherwise be a URL in markdown)
var _region_start = _link_peek+1;
var _region_end = _region_start;
Expand Down

0 comments on commit d73f962

Please sign in to comment.