Move parser back into single file
The only reason to separate the parser files was because my editor setup
was having problems with the file size, but I've since discovered that
those problems were due to a configuration mistake, so let's merge them
together again.
Use emit chunks instead of words in layout
While the summary might sound innocuous, this is a substantial rewrite
of the layout algorithm, which fixes the major layout bug. Before, we'd
emit one word at a time and then finalize their positions once
"something" changed. However, this led to us putting words on the page
too soon in some cases.
Most notably, when right aligned, parameter changes caused the first
part of the line to be emitted along the right margin, and then the rest
of the line to be emitted on top of that. By using emit chunks, we now
only finalize the word position once the entire line is done and ready
to be emitted.
Fixes: https://todo.sr.ht/~reesmichael1/burro/34
Fixes: https://todo.sr.ht/~reesmichael1/burro/35
Add .ligatures command (used for disabling ligatures)
Start breaking parser up into smaller modules
The parser.rs file was getting large enough that Vim's syntax
highlighting was having problems, so this is an attempt to slim it down
some.
Properly consider letter spacing in line width
This fixes a long standing bug where changing the letter spacing could
push text into the margin.
However, this revealed a major problem in the layout algorithm: emitting
one word at a time works fine normally, but when we try to change
parameters in the middle of the line while right aligned, the text is
emitted too far to the right, since the cursor is being advanced from
the right margin.
Fixes: https://todo.sr.ht/~reesmichael1/burro/21
Add support for tab stops
This was a significant amount of work done in the tabs branch. I'll
leave that branch alive for posterity so that all of those commits and
history arent lost.
The only thing missing from this commit is support for using percentages
as the unit for tab indents/lengths. This will be very nice to have, but
will also be a pretty substantial change to the internals, so I decided
to wait until tabs were in master to start on that work.
Add support for relative units
This allows users to change parameters relative to what they currently
for. As an example, if the current point size is 12, then .pt_size[+8]
changes the point size to 20.
Relative units can only be used where it makes sense to use them :)
Trying to use them in, e.g., the .font command will cause an error. They
will be ignored if used in .vspace or .hspace (in a sense, the spacing
commands are already relative to the cursor). However, relative units
should work in pretty much any numeric context, such as .pt_size,
.margins, or .leading.
Implements: https://todo.sr.ht/~reesmichael1/burro/26
Accept units in pt_size command
This is the first step towards adding relative units. It helps avoid
discrepancy between changing the point size and only allowing
.pt_size[+3] while accepting units for other commands.
Fix error on comment at document beginning
This was caused by the lexer expecting all comments to be preceded by a
newline. Everywhere else in the document, this makes sense, because we
require comments to be at the beginning of the line. However, on the
very first line, there is obviously no newline to be followed!
There might be a better way to handle this, but for now, we just check
if there's a comment before we even start the lexing process and discard
it if present.
Fixes: https://todo.sr.ht/~reesmichael1/burro/23
Add explicit .column_break command
Fix bugs with changing page dimensions
There are actually two bugs here that both revealed themselves at the
same time. Previously, if you used a reset argument for page
width/height before another page had actually been emitted, Burro would
crash thinking that there was no previous state to go back to.
Also, when the margins/page size changed, Burro would sometimes start
writing in the right margin instead of continuing on to the next page
when it reached the bottom. This has now been fixed.
Begin adding column support
Columns ended up being *much* trickier than expected (which isn't a
great sign for the post-0.1.0 rewrite to support RTL scripts...), but
this is the first commit of partial support! There are still several
kinks to work out, for example, supporting resizing the margins while
there's more than one column on the page. We'll also add support for
manual column breaks and possibly a balanced column mode.
Also, for some reason, the multi-page example is broken. I decided to
stop delaying this commit any more and fix it later. Every other example
document produces the expected output.
Handle negative values in unit arguments
We might want to also add some checks to make sure that we only have
negative values in reasonable places. For example, we wouldn't want to
have negative margins.
Fixes: https://todo.sr.ht/~reesmichael1/burro/22
Rework distinction between normal and style change commands
Now, any command can be entered at any point on the page, i.e., we no
longer forbid entering (most) commands mid-paragraph. This restriction
was becoming annoying in several ways. It made it impossible to do
things like changing the leading or margins in the middle of a
paragraph, and it meant that a document author had to be very careful
not to use commands in the wrong order, because a "style change" command
would start a new "paragraph," which would then reject a "normal"
command.
This also fixes the weirdness with adding spacing around rules. The
rules.bur example file has been cleaned up to match this.
It's possible that this commit introduces subtly wrong behavior, as we
don't have layout tests. All of the example files produce the correct
results, and we'll be on the lookout for issues in future documents.
Fixes: https://todo.sr.ht/~reesmichael1/burro/14
Begin working on horizontal rules
As of this commit, horizontal rules are "working," but they're still
very finicky. The bug with commands having to be in a certain order is
particularly annoying here. It makes handling the spacing around rules
very tricky.
This also finally adds an example of the curly brace syntax! This is how
we'll pass multiple options to commands.
I've thought about making the spacing around the rule a parameter via
the curly brace syntax, but decided against it for now. Mom doesn't
alter vertical spacing at all when inserting rules, which I think is a
good model to follow. This is open to be revisited once more documents
are set in Burro and we have case studies of the ergonomics.
Add `` and '' syntax for double quotes
Use same commands in README as in demo screenshot
Fix minor typos in README
Update README demo with latest features