Commit graph

38 commits

Author SHA1 Message Date
Pagwin
628f01217e
restructure the tests and assert on whole trees
The suite is now one tasty binary over shared modules, so the Djot
tests can sit next to the Markdown ones without another copy of the
harness:

  tests/Main.hs             the TestTree
  tests/Test/Harness.hs     running a parser inside a property
  tests/Test/Gen.hs         generators, shrinkers, escaping
  tests/Test/Gen/Document.hs  whole document generation
  tests/Markdown/Parse.hs   the Markdown properties

Generated values moved from `pick` to `Arbitrary` instances on
newtypes. `pick` embeds its value with `forAll (return a)` and cannot
shrink; going through Arbitrary gets shrinking back at the cost of
hand written shrinkers, which have to preserve the invariants their
generator established.

IR now derives Eq, and the properties assert against a complete
expected tree rather than pattern matching. The old patterns bound
fresh names that shadowed the generated ones, so they only ever
checked the shape of the tree and never its content.

Test.Gen.Document generates a description of a document which renders
to source and derives its own expected tree, so the two stay in step
while shrinking. Rendering goes through a Syntax record so Djot can
reuse the spec and the expectations. Escaping is a generator level
concern: an Escaper says which characters are special and how (or
whether) they can be written literally.

Two properties fail, both on parser bugs rather than test bugs:

  code_block          fencedCodeBlock inverts its language test, so a
                      fence naming a language reports Nothing. Djot.hs
                      gets this right at src/Djot.hs:354.
  document_round_trip a nested list with more than one item makes the
                      whole list fail to parse and fall back to a
                      paragraph. In listBlock's child parser the second
                      alternative has no `try`, so it fails having
                      consumed the first item's indentation. The
                      existing nesting tests only ever used one nested
                      item.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 16:15:33 -04:00
Pagwin
d31bf0233e
swap hedgehog out for QuickCheck
The test suite now runs on tasty + tasty-quickcheck. Translation is
mechanical: `property`/`forAll`/`lift` become
`monadicIO`/`pick`/`run`, `success`/`fail` become `pure ()`/`stop`
with a counterexample, and Hedgehog's ranged generators are replaced
by a `linear` helper that scales with QuickCheck's size parameter.
Shrinking is dropped since QuickCheck can't shrink these while keeping
the generated text within the ranges the assertions assume.

The expected-value patterns were also stale relative to the IR
(`LI`'s `child` field is gone, blocks carry a trailing `Attrs`, list
types carry a `style`), so they've been updated to match. The
structural checks are otherwise unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 15:39:36 -04:00
Pagwin
d695910c7c
implement the djot parser
Fills out src/Djot.hs, which was a skeleton of `error "todo"` stubs.

Three layers, so container prefixes and indentation never have to be
threaded through the parser state:

  - line primitives (rawLine/peekLine/lineWhen/dedent): block parsers peek
    at the next line, decide whether they want it, then consume it
  - container blocks strip their prefix off the lines they own and re-parse
    the result with subParse, a rank-2 helper that runs a polymorphic parser
    at Identity and shifts error offsets back into the outer input
  - inline content is a second pass over the text a block collected

Blocks: headings, paragraphs, block quotes, fenced code, raw blocks, divs,
tables (alignments, `^` captions, escaped pipes), footnote and reference
definitions, block attributes, thematic breaks, and lists -- bullet,
ordered (decimal/alpha/roman, `.`/`)`/`(n)`), task, and definition. Tight
lists unwrap their paragraphs to Transparent.

Inlines: emphasis and its braced forms, verbatim, raw inline, math, links,
reference links, images, autolinks, spans, footnote references, symbols,
escapes, hard breaks, attribute sets, and smart punctuation.

Two spots where the IR came up short:

  - there is no reference image, so for `![alt][ref]` the label lands in
    the url field
  - unordered lists get style = Nothing rather than the bullet character,
    which HTML.hs would otherwise emit as an invalid type="-"

Also includes the psb.cabal fix dropping OverloadedRecordUpdate, without
which Psb.Main does not build.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 15:15:33 -04:00
Pagwin
f062d2c1dc
convenient extension 2026-05-05 14:32:56 -04:00
Pagwin
aa69b3f6ef
removed LLM code, unfortunately the only way to do lists correctly so I can pull out structure is to do it myself 2026-04-13 14:07:38 -04:00
Pagwin
b6a689868b
Brought in code by Gemini for handling lists and Task lists
lists and task lists are a PITA to handle, I may need to handle them
myself in the future but that'll probably become clear via testing
rather than simply doing it as is because the parsing logic is annoying
2026-04-10 16:17:37 -04:00
Pagwin
5073fdb04b
started on Djot implementation 2026-04-06 21:18:15 -04:00
Pagwin
22f4f89137
naive refactor of markdown generation for the new IR 2026-04-06 15:17:39 -04:00
Pagwin
c90d2e45b8
todo stuff and fixing images 2026-04-03 17:48:26 -04:00
Pagwin
b3808f4136
MVP Bundling is now implemented
This commit gets bundling to the point where it can be used now

TODO:
- Get ESBuild Stdout/stderr to not pop up in psb output
- figure out how to split off map files so I'm not shunting them into
  script tags
2026-02-23 17:14:31 -05:00
Pagwin
c3637bd12d
added a module for bundling 2026-01-31 19:53:20 -05:00
Pagwin
aeb70675a9
factored out some useful parsing utilities to a separate file and began work on javascript tokenization 2025-12-26 14:02:29 -05:00
Pagwin
65e7091899
tree-sitter seems necessary 2025-12-26 00:57:50 -05:00
Pagwin
dfeffdef2b
beginning work on CSS and JS minification 2025-12-25 23:24:33 -05:00
Pagwin
c4ff078785
moved everything into src for ease of testing 2025-12-05 19:42:15 -05:00
Pagwin
d9e46a1a83
refactored to have most stuff in a library 2025-11-30 21:19:28 -05:00
Pagwin
874803d89e
made test run again 2025-11-28 13:43:32 -05:00
Pagwin
a69ddb2f92
cabal check nits fixed 2025-11-28 13:30:51 -05:00
Pagwin
10ea8c2177
version bump due to being close to the point where I'll start using this 2025-11-26 21:02:22 -05:00
Pagwin
9e9117db52
on the start of trying to make parser more generic for no good reason 2025-11-22 21:01:21 -05:00
Pagwin
219dce5abf
refactored Utilties to split off FilePath and Action functions into their own files among other refactoring 2025-11-22 19:00:43 -05:00
Pagwin
b930a78f66
made logging in parsing more generic 2025-11-16 14:51:19 -05:00
Pagwin
ebcb13929a
pretty errors and swapped to ParsecT to do debugging stuff 2025-11-14 00:37:14 -05:00
Pagwin
72d8892a20
ported to megaparsec for better error messages 2025-11-12 17:13:57 -05:00
Pagwin
a679bbd373
added more useful haskell features to cabal file 2025-11-06 13:37:43 -05:00
Pagwin
b1f9a8d2f9
removed pandoc fully and will now use a stale build to determine whether or not things are working 2025-11-04 22:22:37 -05:00
Pagwin
d61fd86b76
hooked everything up to make use of new markdown parsing, just need to write the code to generate HTML 2025-11-01 17:01:59 -04:00
Pagwin
016d50aff1
starting to move towards making my own markdown parser 2025-07-24 18:39:40 -04:00
Pagwin
4a5d5e541a
new setup for how I'm trying to tackle this 2025-05-09 21:13:22 -04:00
Pagwin
07218a32a6
restructuring handling of markdown 2025-05-09 20:08:42 -04:00
Pagwin
2027c8569f
more scaffolding 2025-02-05 12:19:18 -05:00
Pagwin
5bf0487023
scaffolding for yeeting pandoc 2025-02-05 11:21:57 -05:00
Pagwin
82c0fe7631
minor cabal file change 2025-02-05 11:19:45 -05:00
Pagwin
c7043b5fc3
lots of things to make github action maybe work 2024-12-30 18:30:06 -05:00
Pagwin
8f8b33517a
seems to be working now 2024-08-01 01:50:40 -04:00
Pagwin
daeaf9b9ec
made it so date is in the metadata instead of the filename 2024-07-30 01:49:28 -04:00
Pagwin
9c1dad567b
lots of progress but still has compiler errors 2024-07-20 17:36:55 -04:00
Pagwin
d364237e05
initial commit after moving out of repo 2024-07-20 16:49:21 -04:00