Skip to content

Commit

Permalink
Merge 21cc684 into 40fd272
Browse files Browse the repository at this point in the history
  • Loading branch information
Omikhleia committed Mar 23, 2023
2 parents 40fd272 + 21cc684 commit bd27fad
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 4 deletions.
13 changes: 13 additions & 0 deletions classes/plain.lua
Expand Up @@ -243,6 +243,19 @@ function class:registerCommands ()
SILE.call("font", { weight = 700 }, content)
end)

self:registerCommand("code", function (options, content)
-- IMPLEMENTATION NOTE:
-- The \code command came from the url package, though used in plenty of
-- places. It was referring to the verbatim:font from the verbatim
-- package, which _should_ be sort of unrelated.
-- Trying to untangle the things here, by introducing the
-- definition from the former, but it's of sub-quality...
-- The ugly -3 size is a HACK of sorts.
options.family = options.family or "Hack"
options.size = options.size or SILE.settings:get("font.size") - 3
SILE.call("font", options, content)
end)

self:registerCommand("nohyphenation", function (_, content)
SILE.call("font", { language = "und" }, content)
end)
Expand Down
12 changes: 8 additions & 4 deletions packages/url/init.lua
Expand Up @@ -147,13 +147,13 @@ function package:registerCommands ()
secondaryPenalty = secondaryPenalty,
worsePenalty = worsePenalty
})
SILE.call("code", {}, result)
SILE.call("urlstyle", {}, result)
end)
end, "Inserts penalties in an URL so it can be broken over multiple lines at appropriate places.")

self:registerCommand("code", function (options, content)
SILE.call("verbatim:font", options, content)
end)
self:registerCommand("urlstyle", function (options, content)
SILE.call("code", options, content)
end, "Hook that may be redefined to change the styling of URLs")

end

Expand All @@ -177,6 +177,10 @@ To typeset a URL and also make it an active hyperlink, use the \autodoc:command{
but with the URL passed as argument.
The breaks are controlled by two penalty settings: \autodoc:setting{url.linebreak.primaryPenalty} for preferred breakpoints and, for less acceptable but still tolerable breakpoints, \autodoc:setting{url.linebreak.secondaryPenalty}—its value should logically be higher than the previous one.
The \autodoc:command{\urlstyle} command hook may be overridden to change the style of URLs.
By default, they are typeset as “code”.
\end{document}
]]

Expand Down
52 changes: 52 additions & 0 deletions tests/feat-urlstyle.expected
@@ -0,0 +1,52 @@
Set paper size 297.6377985 419.5275636
Begin page
Mx 14.8819
My 26.2947
Set font Hack;7;400;;normal;;;LTR
T 156 211 211 198 205 w=21.0718 (https)
Mx 35.9537
T 583 w=4.2144 (:)
Mx 40.1680
T 599 w=4.2144 (/)
Mx 44.3824
T 599 w=4.2144 (/)
Mx 48.5967
T 205 158 172 139 w=16.8574 (sile)
Mx 65.4542
T 656 w=4.2144 (-)
Mx 69.6685
T 211 233 198 139 205 139 211 211 139 201 w=42.1436 (typesetter)
Mx 111.8121
T 592 w=4.2144 (.)
Mx 116.0264
T 184 201 151 w=12.6431 (org)
Mx 128.6695
T 599 w=4.2144 (/)
Mx 14.8819
My 38.2947
Set font Gentium Plus;10;400;;normal;;;LTR
T 31 w=4.3896 (<)
Mx 19.2715
T 75 87 87 83 86 w=21.5625 (https)
Mx 40.8340
T 29 w=2.2900 (:)
Mx 43.1241
T 18 w=4.6924 (/)
Mx 47.8165
T 18 w=4.6924 (/)
Mx 52.5088
T 86 76 79 72 w=13.9014 (sile)
Mx 66.4102
T 16 w=3.3691 (-)
Mx 69.7794
T 87 92 83 72 86 72 87 87 72 85 w=42.2363 (typesetter)
Mx 112.0157
T 17 w=2.2900 (.)
Mx 114.3057
T 82 85 74 w=13.8672 (org)
Mx 128.1729
T 18 w=4.6924 (/)
Mx 132.8653
T 33 w=4.3896 (>)
End page
Finish
11 changes: 11 additions & 0 deletions tests/feat-urlstyle.sil
@@ -0,0 +1,11 @@
\begin[papersize=a6]{document}
\neverindent
\nofolios
\use[module=packages.url]

\url{https://sile-typesetter.org/}

\define[command=urlstyle]{<{\process}>}
\url{https://sile-typesetter.org/}

\end{document}

0 comments on commit bd27fad

Please sign in to comment.