Skip to content

feat: add <writing_mode> for vertical layout - #202

Open
DanielNg0729 wants to merge 1 commit into
doclang-project:mainfrom
DanielNg0729:feat/writing-mode
Open

DanielNg0729 wants to merge 1 commit into
doclang-project:mainfrom
DanielNg0729:feat/writing-mode

Conversation

@DanielNg0729

Copy link
Copy Markdown
Contributor

Hi maintainers, this PR adds a way to declare vertical layout (#169). An example is Japanese or Chinese text in vertical lines that follow each other from right to left. This is a first proposal, so I am happy to change the name, the values, or the place of the element.

Proposal

A new empty element, <writing_mode value="..."/>, follows the pattern of <layer>:

<doclang>
  <head>
    <writing_mode value="vertical_rl"/>          <!-- document default -->
  </head>
  <heading>第一章</heading>
  <text>吾輩は猫である。名前はまだ無い。</text>
  <page_footer>
    <writing_mode value="horizontal_tb"/>        <!-- override for this element -->
    12
  </page_footer>
</doclang>
  • Values: horizontal_tb, vertical_rl and vertical_lr. They correspond to the CSS writing-mode values horizontal-tb, vertical-rl and vertical-lr, written in snake_case like read_only.
  • value is required. An element without <writing_mode> already inherits a writing mode, so an empty <writing_mode/> would have no use.
  • In <head>: the element sets the document default. Schematron allows at most one there.
  • In the element head: the element comes after <layer> and before <location>. It applies to the element and its descendants. List items and table cells share the element head, so they can use it too, for example for a vertical header cell in a horizontal table.
  • Inheritance: an element without <writing_mode> takes the writing mode of its nearest ancestor that declares one. Then it takes the document default, and then horizontal_tb.
  • What does not change:
    • The content stays in reading order.
    • <location> keeps its coordinate system (the top-left corner of the page).
    • The element is independent of <rtl>, which still marks right-to-left text in a line. CSS also keeps writing-mode and direction separate.
  • Later: Annex D lists finer vertical typography as a possible extension: upright or rotated Latin, tate-chū-yoko, and ruby.

Changes

  • doclang/doclang.xsd: a new writing_mode element, added to the element_head group after layer. The global declaration also validates the element inside the lax <head>.
  • doclang/doclang.sch:
    • writing_mode is added to every list of element-head names: element-head placement, list, track, table, picture body, list items, and table cells.
    • A new pattern, head-writing-mode-unique, allows at most one writing_mode in <head>.
  • spec.md:
    • The Element Head list includes the new element.
    • A new "Writing Mode" usage section has three examples.
    • The token vocabulary has a new row for <writing_mode value=".
    • Annex D has a new bullet, and the Bibliography has a new entry for CSS Writing Modes Level 3.
    • Annex A is regenerated from the workbook.
  • reference/input/reference.xlsx: one new elements row and one new attributes row. No existing row changes.
  • doclang/tokenization.py: a new token, '<writing_mode value="'.
  • doclang/migration/_steps/next.py: the migration step removes writing_mode and records a "dropped" change for each element.
  • Test fixtures:
    • 3 valid fixtures: a head default with overrides, the full element-head order, and a vertical table and list with cell and item overrides.
    • 8 invalid fixtures: a wrong value, a missing value, a wrong value in <head>, after <location>, before <layer>, in the body, directly in <doclang>, and twice in <head>.
  • tests/test_migration.py: a new test for the dropped elements and their reported locations.
  • tests/test_validation.py:
    • test_newer_declared_version_falls_back_to_the_released_head expected the head schema to be identical to the released 0.8 schema. This stops being true with any head change.
    • The test now expects "(unreleased development version)", and its new name is test_newer_declared_version_falls_back_to_the_head.

Issue resolved by this Pull Request:
Resolves #169

Checklist:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

DocLang had no way to declare that lines are vertical, e.g. in Japanese or
Chinese text where lines run top to bottom and follow each other from right
to left.

Add `<writing_mode value="horizontal_tb|vertical_rl|vertical_lr"/>`. In
`<head>` it sets the document default. In an element head (after `<layer>`,
before `<location>`) it applies to the element and its descendants. Content
stays in reading order and `<location>` keeps its coordinate system.

Schematron allows at most one `<writing_mode>` in `<head>`. The migration
step drops the element, and the token vocabulary gets
`<writing_mode value="`.

Signed-off-by: Daniel Nguyen <danielnguyenh07@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider adding support for vertical layout

1 participant