Skip to content

Commit

Permalink
feat: Support bare percentage in width and height options
Browse files Browse the repository at this point in the history
  • Loading branch information
Omikhleia authored and Didier Willis committed Mar 13, 2024
1 parent 1eed7d9 commit daa458b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
6 changes: 3 additions & 3 deletions examples/sile-and-djot.dj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The core concepts in Djot mirror those of Markdown, featuring inline and block e
Attributes are additional properties or metadata that can be associated with certain elements, allowing for more fine-grained control over the appearance and behavior of elements.


![Djot concepts at a glance.](./djot-concept-simplified.svg){width="75%lw"}
![Djot concepts at a glance.](./djot-concept-simplified.svg){width="75%"}


## Attributes
Expand Down Expand Up @@ -346,14 +346,14 @@ This inline "manicule" is obtained with:

Files in Graphviz DOT graph language (`.dot`) are supported and rendered as images, when the *embedders.sile* collection is properly configured.

![The *markdown.sile* ecosystem (simplified).](./markdown-sile-schema.dot){width="90%lw"}
![The *markdown.sile* ecosystem (simplified).](./markdown-sile-schema.dot){width="90%"}

This image is obtained with the following syntax.

{custom-style=CodeBlock}
:::
```
![The *markdown.sile* ecosystem (simplified).](./markdown-sile-schema.dot){width="90%lw"}
![The *markdown.sile* ecosystem (simplified).](./markdown-sile-schema.dot){width="90%"}
```
:::

Expand Down
4 changes: 2 additions & 2 deletions examples/sile-and-markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,13 @@ This inline "manicule" is obtained with:

Files in Graphviz DOT graph language (`.dot`) are supported and rendered as images, when the **embedders.sile** collection is properly configured.

![The **markdown.sile** ecosystem (simplified).](./markdown-sile-schema.dot){width="90%lw"}
![The **markdown.sile** ecosystem (simplified).](./markdown-sile-schema.dot){width="90%"}

This image is obtained with the following syntax.

::: {custom-style=CodeBlock}
```
![The **markdown.sile** ecosystem (simplified).](./markdown-sile-schema.dot){width="90%lw"}
![The **markdown.sile** ecosystem (simplified).](./markdown-sile-schema.dot){width="90%"}
```
:::

Expand Down
17 changes: 17 additions & 0 deletions packages/markdown/cmbase.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,23 @@ function package:_init (_)
end)
end

function package:registerCommand(name, func, help, pack)
local tweakCommandWithKnownOptions = function (options, content)
options = options or {}
-- Tweak known options to be compatible with SILE units.
-- width and height in percentage are replaced by line and frame relative
-- units, respectively.
if options.width and type(options.width) == "string" then
options.width = options.width:gsub("%%$", "%%lw")
end
if options.height and type(options.height) == "string" then
options.height = options.height:gsub("%%$", "%%fh")
end
return func(options, content)
end
base.registerCommand(self, name, tweakCommandWithKnownOptions, help, pack)
end

--- Register a style (as in resilient packages).
function package:registerStyle (name, opts, styledef)
return self.styles:defineStyle(name, opts, styledef, self._name)
Expand Down

0 comments on commit daa458b

Please sign in to comment.