Commit graph

29 commits

Author SHA1 Message Date
ilja
418068793f Make parser FEP-c16b compliant
This is basically a rewrite of big parts of the parser, introducing a lot of breaking
changes.

The parser was originally written mostly as an exercise for myself and not really aimed
as-is for practical usage. An adapted version has been used in Akkoma, however, and
this pointed out serious flaws in how MFM was done in general on the fediverse. This
was discussed [on the Foundkey issue
tracker](FoundKeyGang/FoundKey#343) and a better way was
decided. At the time of writing, this is being formalised into
[FEP-c16b](https://codeberg.org/fediverse/fep/src/branch/main/fep/c16b/fep-c16b.md).
This commit rewrites this parser to be FEP-c16b compliant.

Previously, the parser had knowledge of the specific MFM functions. This was useful for
setting default attribute values and adding specific CSS. This is not the case any
more. The parser has no knowledge of specific MFM functions any more. It also had an
understanding of the concept of newlines, this isn't the case any more either. It only
does a "simple" translation from MFM function notation to FEP-c16b compliant HTML.

Because of this, we also don't add CSS any more. It's up to the software who uses this
HTML to decide what functions they want to provide and use the correct CSS. In practice
the CSS from this parser was never used in Akkoma, so it's not really a loss.
2024-08-10 20:13:48 +02:00
ilja
a5faf98ecd Revert "don't append styles"
This reverts commit 5e8723e54b.
2024-08-10 19:55:14 +02:00
ilja
9358f483af Revert "fix animation name"
This reverts commit 03901025b0.
2024-08-10 19:55:13 +02:00
ilja
69b8a27359 Revert "include class on spans"
This reverts commit 5054e0ba1e.
2024-08-10 19:55:11 +02:00
ilja
74f7f5964d Revert "use html generator for some things, fix x(x) styling"
This reverts commit 48d0da81e0.
2024-08-10 19:55:10 +02:00
ilja
61f503a1bf Revert "update git URL"
This reverts commit 51282dd6a7.
2024-08-10 19:55:08 +02:00
ilja
6a8445612b Revert "add classes to a bunch of things"
This reverts commit 912fba8115.
2024-08-10 19:55:07 +02:00
ilja
db79aa92dd Revert "Revert "use html generator for some things, fix x(x) styling""
This reverts commit f124e2812e.
2024-08-10 19:55:01 +02:00
ilja
5563d3ed9b Revert "revert usage of temple"
This reverts commit b21ab77540.
2024-08-10 19:54:30 +02:00
b21ab77540 revert usage of temple 2023-08-06 18:53:50 +01:00
f124e2812e Revert "use html generator for some things, fix x(x) styling"
This reverts commit 48d0da81e0.
2023-08-06 18:47:00 +01:00
912fba8115 add classes to a bunch of things 2022-08-24 10:01:48 +01:00
51282dd6a7 update git URL 2022-08-23 12:13:14 +01:00
48d0da81e0 use html generator for some things, fix x(x) styling 2022-08-23 12:07:35 +01:00
5054e0ba1e include class on spans 2022-08-18 03:36:35 +01:00
03901025b0 fix animation name 2022-08-18 03:22:01 +01:00
5e8723e54b don't append styles 2022-08-18 02:40:10 +01:00
Ilja
1bf36d1f52 Code review part 3
* <https://ilja.space/notice/ALpd6nux5hT2nsfetM>
    * Previous commit: `|> fill_props(token) after the cond` in the parser
    * Previous commit: Don't use intention-specific data in the tokens (e.g. left is reverse, x is mfm-spinX)
* <https://ilja.space/notice/ALpcK6W59UjkIUofU8>
    * This commit: Use less files
* Previous commit: Change nested if-statement in mfm.ex to `cond do`

I also added some more and better info to the README.md and moduledocs.
2022-07-25 14:13:43 +02:00
Ilja
a8dd3dd719 Code review part 2
* <https://ilja.space/notice/ALpd6nux5hT2nsfetM>
    * Previous commit: `|> fill_props(token) after the cond` in the parser
    * This commit: Don't use intention-specific data in the tokens (e.g. left is reverse, x is mfm-spinX)
* <https://ilja.space/notice/ALpcK6W59UjkIUofU8>
    * TODO: Use less files
* Previous commit: Change nested if-statement in mfm.ex to `cond do`
2022-07-25 09:29:24 +02:00
Ilja
ecd3f750cb Code review
* <https://ilja.space/notice/ALpd6nux5hT2nsfetM>
    * This commit: `|> fill_props(token) after the cond` in the parser
    * TODO: Don't use intention-specific data in the tokens (e.g. left is reverse, x is mfm-spinX)
* <https://ilja.space/notice/ALpcK6W59UjkIUofU8>
    * TODO: Use less files
* This commit: Change nested if-statement in mfm.ex to `cond do`
2022-07-25 09:18:22 +02:00
Ilja
0a2894f07a Fix bug when starting with $-sign
When a text token was running, it wouldn't stop on a $-sign if it wasn't followed with a "[".
This is good.

But when a token was finished and the next char was a $-sign, it would consider it an MFMOpen, even when not followed by a "[".
This is now fixed.
2022-07-25 01:21:02 +02:00
Ilja
ed970aa77d Move Encoder logic to own module 2022-07-25 00:44:45 +02:00
Ilja
d9ffd99e4d Convert a tree to HTML + formatting + docs 2022-07-24 16:32:57 +02:00
Ilja
5f63b7e4bd Make it not crash when tag not properly ended
The following cases are now tested and fixed so they don't crash:
* Providing a "]" without there being a mfm token opened.
* Opening a tag without closing. E.g. "$[spin " and "$[spin chocolatine".
* Starting a tag without finishing it. E.g. "$[sp".
2022-07-24 10:28:29 +02:00
Ilja
5bb5620778 Make parser work for multiple token input
We can now handle multiple tokens and nesting.
2022-07-24 09:04:01 +02:00
Ilja
45519a3c2a Make parser work for single token input
We can handle all needed tokens.
We still need to test for multiple tokens and for nesting.
2022-07-24 07:55:55 +02:00
Ilja
733388fa6e Change Lexer to use a data structure for tokens 2022-07-23 20:17:34 +02:00
Ilja
4748d833b2 Make Reader and Lexer work 2022-07-23 19:15:08 +02:00
Ilja
cf49876a47 First commit
Initialise repository
2022-07-23 16:51:13 +02:00