aboutsummaryrefslogtreecommitdiffstats
path: root/make
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2019-03-28 11:58:58 +0100
committerBjörn Gustavsson <[email protected]>2019-04-04 12:30:20 +0200
commit88d9cdc7ba60e3b2c996d5e06a54d92a62b0afc4 (patch)
tree942d6d8082f7a6d433cf69aacc4a312c7894b170 /make
parentd49d01571ba9ab5bc28f470905269ab98c96b9af (diff)
downloadotp-88d9cdc7ba60e3b2c996d5e06a54d92a62b0afc4.tar.gz
otp-88d9cdc7ba60e3b2c996d5e06a54d92a62b0afc4.tar.bz2
otp-88d9cdc7ba60e3b2c996d5e06a54d92a62b0afc4.zip
emd2exml: Allow short names of anchors for internal links
Links within a document required writing the entire name of the generated anchor. Basically, that makes it possible to writing internal links that will be translated correctly both by emd2exml and by Github.
Diffstat (limited to 'make')
-rwxr-xr-xmake/emd2exml.in35
1 files changed, 29 insertions, 6 deletions
diff --git a/make/emd2exml.in b/make/emd2exml.in
index 24837696f4..0d14b961a6 100755
--- a/make/emd2exml.in
+++ b/make/emd2exml.in
@@ -471,9 +471,14 @@ link_or_image(Str, Type) ->
{["<url href=\"", text(Url), "\">", text(Text), "</url>"],
Cont2};
{seealso, SeeAlso, _Title, Cont2} ->
- {["<seealso marker=\"", text(SeeAlso), "\">",
- text(Text), "</seealso>"],
- Cont2};
+ case internal_seealso(SeeAlso) of
+ no ->
+ {["<seealso marker=\"", text(SeeAlso), "\">",
+ text(Text), "</seealso>"],
+ Cont2};
+ {yes, SeeAlsoKey} ->
+ {delayed, link, SeeAlsoKey, text(Text), Cont2}
+ end;
{image, Image, Title, Cont2} ->
{["<image file=\"", text(Image), "\"><icaption>",
text(Title), "</icaption></image>"],
@@ -485,6 +490,11 @@ link_or_image(Str, Type) ->
end
end.
+internal_seealso("#" ++ Marker) ->
+ {yes, {internal, Marker}};
+internal_seealso(_) ->
+ no.
+
link_or_image_text([$\\,C|Cs], Acc) ->
link_or_image_text(Cs, [C|Acc]);
link_or_image_text([$]|_Cs], "") ->
@@ -615,8 +625,10 @@ put_title(S, 1, Title) ->
put_title(#state{mlist = MList0,
toc = TOC} = S0, H, Title) ->
TitleStr = text(Title),
- MList1 = [mk_lvl_marker(Title) | MList0],
+ TitleMarker = mk_lvl_marker(Title),
+ MList1 = [TitleMarker | MList0],
Marker = mk_marker(MList1),
+ MarkerKey = string:lowercase(TitleMarker),
S1 = chk_h1(H,
S0#state{toc = [TOC,
lists:duplicate(H," "),
@@ -624,13 +636,15 @@ put_title(#state{mlist = MList0,
"<seealso marker=\"#",Marker,"\">",
TitleStr,"</seealso>",nl()],
h = H,
- mlist = MList1}),
+ mlist = MList1
+ }),
S2 = put_chars(S1, ["<marker id=\"", Marker, "\"/>",nl()]),
+ S3 = write_delayed(S2, {internal, MarkerKey}, {"#" ++ Marker, ""}),
{STag, ETag} = case H > ?MAX_HEADING of
true -> {"<p><strong>", "</strong></p>"};
false -> {"<title>", "</title>"}
end,
- put_chars(S2, [STag, TitleStr, ETag, nl()]).
+ put_chars(S3, [STag, TitleStr, ETag, nl()]).
setext_heading(H, #state{line = Line, h = OldH} = S0) ->
S1 = sections(H, OldH, S0),
@@ -1219,6 +1233,15 @@ complete_output(S, [], Out) ->
Out]};
complete_output(S, [{delayed, IX}|Rest], Out) ->
complete_output(S, Rest, [read_delayed(S, IX)|Out]);
+complete_output(S, [{delayed, {internal, Key0}, {link, Text, _Line}}|Rest], Out) ->
+ Key = [C || C <- Key0, C =/= $_],
+ case read_delayed(S, {internal, Key}) of
+ {value, {Url, _}} ->
+ complete_output(S, Rest, [mk_link(Text, Url)|Out]);
+ none ->
+ Url = "#" ++ Key0,
+ complete_output(S, Rest, [mk_link(Text, Url)|Out])
+ end;
complete_output(S, [{delayed, Key, {link, Text, Line}}|Rest], Out) ->
case read_delayed(S, Key) of
{value, {Url, _Title}} ->