Skip to content

Commit d0a86a1

Browse files
authored
fix(*): adjust text for internal link (#105)
* fix(*): adjust text shown for internal link * fix: typst font size
1 parent 7fb2836 commit d0a86a1

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

oi-wiki-export-typst/oi-wiki-export.typ

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,20 @@
181181
)
182182
#show enum: set block(width: 100%)
183183

184-
#set ref(supplement: el => [#el.body#h(-.333em)])
184+
#show ref: it => {
185+
let el = it.element
186+
if el != none and el.func() == heading and it.form == "normal" and it.supplement != auto {
187+
link(
188+
el.location(),
189+
it.supplement + text(size: 0.9em, "" + numbering(
190+
el.numbering,
191+
..counter(heading).at(el.location())
192+
) + "@p" + str(el.location().page()))
193+
)
194+
} else {
195+
it
196+
}
197+
}
185198
#show ref: set text(fill: cmyk(0%, 100%, 100%, 0%))
186199

187200
#show footnote.entry: it => {

oi-wiki-export/oi-wiki-export.tex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,11 @@
288288
\newcommand{\lt}{\symbol{"3C}} % less than
289289
\newcommand{\gt}{\symbol{"3E}} % greater than
290290

291+
% To generate internal links with section number and page number.
292+
\newcommand{\linkwithpage}[2]{%
293+
\hyperref[#1]{#2\scalebox{0.9}{→\ref*{#1}@p\pageref*{#1}}}%
294+
}
295+
291296
\makeatother
292297
\begin{document}
293298
\maketitle

remark-latex/lib/compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export default function compiler(options) {
211211
if (isInternalLink(url)) {
212212
const location = toPrefix(joinRelative(url, options));
213213
return location !== "" && raw !== ""
214-
? "\\hyperref[sect:{0}]{{1}}".format(location, children)
214+
? "\\linkwithpage{sect:{0}}{{1}}".format(location, children)
215215
: "";
216216
} else {
217217
const location = escape(url);

remark-typst/lib/compiler.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ function toTypst(tree, options) {
110110
const makeLink = function (url) {
111111
if (isInternalLink(url)) {
112112
const location = toPrefix(joinRelative(url, options))
113-
114-
return (location !== '') ? `@${location}` : ''
113+
const children = all(node, parse).join('')
114+
115+
return location !== '' ? '@{0}[{1}]'.format(location, children) : ''
115116
} else {
116117
const location = url.replace(/\\/g, '\\\\')
117118
++linkIndex

0 commit comments

Comments
 (0)