Skip to content

Styling specification for framed (paragraph/block-level) content - RFC #198

Description

@Omikhleia

To make "framed boxes" in my Djot or Markdown documents, I used a technique abusing "custom alignments".

These SIL/Lua-escape are not ideal, and cumbersome (an not that well defined, why one had minimize=true and not the other, why we have padding and enlarge, etc.

```=sile
\define[command=customframe]{\center{\roughbox[bordercolor=#66a0b3,
  fillcolor=220,padding=15pt, enlarge=true]{\parbox[width=90%lw, minimize=true]{\process}}}}
\define[command=customblockframe]{\center{\framebox[bordercolor=#66a0b3,
  shadow=true,
  fillcolor=250,
  padding=4pt,
  shadowcolor=220]{\parbox[width=90%lw]{\process}}}}
```

```=sile-lua
-- Tapping into the internal scratch variable of the resilient.styles
-- package is not a good practice.
SILE.scratch.styles.alignments["fancy-framed"] = "customframe"
local class = SILE.documentState.documentClass
class:registerStyle("FramedPara", {}, {
  paragraph = {
    before = { skip = "medskip" },
    after = { skip = "medskip" },
    align = "fancy-framed"
  }
})

SILE.scratch.styles.alignments["shadow-framed"] = "customblockframe"
local class = SILE.documentState.documentClass
class:registerStyle("CodeBlock", {}, {
  paragraph = {
    before = { skip = "smallskip" },
    after = { skip = "smallskip" },
    align = "shadow-framed"
  }
})
```

One could perhaps want a more "native" way to specify framed boxes within the resilient styling paradigm, without having to define custom alignments and custom commands....

For the record, the existing ⟨decoration specification⟩ is an object which can contain any of the following elements.

style:
  ...
  decoration:
    line: "underline|strikethrough|redacted|mark"
    color: "⟨color specification⟩"
    thickness: "⟨dimen⟩"
    rough: true|false
    fillstyle: "hachure|solid|zigzag|cross-hatch|dashed|zigzag-line"

But that's for inline text decorations (underlining, etc.). It only resembles some of the options for boxes, since some of the underlying implementation is shared.

For block-level decorations (e.g. on paragraph blocks), we may introduce a "frame" wrapper element.

Maybe something like this:

paragraph:
  ... (other paragraph style options)
  frame:
    inner: "⟨paragrah style name⟩" # applies the inner style to the content of the frame
    decoration:
      type: "square"
      stroke:
        width: 0.4pt   # 0 = no stroke, absence = default stroke
        color: "#333"
      fill:
        color: "#eee"
      padding: 10pt
      shadow: # No shadow if absent
        size: 5pt # absence = default shadow size
        color: "#ccc"

paragraph:
  ...
  frame:
    inner: "⟨paragrah style name⟩"
    decoration:
      type: "rounded"
      cornersize: 6pt
      stroke:
        width: 1pt   # 0 = no stroke
        color: "#333"
      fill:
        color: "#eee"
      padding: 10pt
      shadow:
        size: 5pt
        color: "#ccc"

paragraph:
  ...
  frame:
    inner: "⟨paragrah style name⟩"
    decoration:
      type: "rough"
      stroke:
        width: 1pt
        color: "#333"
      fill:
        color: "#eee"
        style: hachure
      padding: 10pt
      roughness: 1.5
      bowing: 0.5
      preserve: true # preserve vertices positions (no randomization)
      singlestroke: true # multiple strokes by default

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions