Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert box commands #69

Open
Myriad-Dreamin opened this issue Dec 26, 2023 · 0 comments
Open

Convert box commands #69

Myriad-Dreamin opened this issue Dec 26, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@Myriad-Dreamin
Copy link
Collaborator

Myriad-Dreamin commented Dec 26, 2023

No plan, but some direction:

  • find a way of ignoring all box related commands, so that it just compiles in typst instead of really layout something.
  • implement kern commands
  • implement glue commands
  • implement paragraph commands

Materials and ideas

Initial Idea is following.

  • The boxes are allocated by converter.
  • We may have infinite virtual box registers, since holding limit of 256 is just less meaningful but depends on implementation.
  • We won't calculate any size of boxes, but converting them with typst scripting.
    That means, any failed conversions will just make MiTeX ignore layout request from TeX Code.
  • For code converting layout, measure for box and box conditions:
    #locate(loc => layout(size => {
      // converted code here
    }))

Examples

Example 1 (paragraph):

\everypar{\setbox\parbox=
\vbox\bgroup\everypar{}%
\def\par{\endgraf\HandleLines
\egroup\box\parbox}}
\def\HandleLines{ ... \lastbox ... }

Example 2 (box):

\newbox\linebox \newbox\snapbox
\def\eatlines{
\setbox\linebox\lastbox % check the last line
\ifvoid\linebox
\else % if it's not empty
\unskip\unpenalty % take whatever is
{\eatlines} % above it;
% collapse the line
\setbox\snapbox\hbox{\unhcopy\linebox}
% depending on the difference
\ifdim\wd\snapbox<.98\wd\linebox
\box\snapbox % take the one or the other,
\else \box\linebox \fi
\fi}
@OrangeX4 OrangeX4 added the enhancement New feature or request label Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants