Use FEP-c16b: Formatting MFM functions #410

Open
ilja wants to merge 10 commits from ilja/akkoma-fe:use_fep-c16b_formatting_mfm_functions into develop
Contributor

Related AkkomaGang/akkoma#381

After discussing in https://akkoma.dev/FoundKeyGang/FoundKey/issues/343 a scrubber-friendly way was discovered for representing the MFM functions in HTML. These are the front-end changes needed for that. This should fix the MFM in Akkoma and provide compatibility for the same MFM functions as Foundkey has.

In this PR we:

  • first we need to add the Foundkey SCSS
    • I added this in a separate commit so I could add Johan as author. If there's something I should do different, do let me know.
  • then adapt where needed, including backwards compatibility for posts in the "old" format
  • make sure the setting for disabling MFM still works
  • then we need to add JS for the data attr variables
  • make sure all supported tags are added to ./src/components/emoji_input/suggestor.js
  • does it work as expected?
    • Do the functions display properly, see "Extra notes" below
      • For custom emojis in x2, x3, x4, tada, the sizes that Foundkey uses are used
      • Otherwise the size that Akkoma already used (38px) is kept
    • Don't allow going outside of the borders of the status (we use overflow: hidden; on the StatusBody now)
    • other things someone can think of?

Broader scope where this PR is part of:

Extra notes:

  • Sparkle has not been implemented here. It didn't work before and it requires some extra JS. This is already a strict improvement, and also a very fundamental change over multiple repositories. So it seems better to me, to do sparkle in a separate PR.

  • We can check MFM on https://genau.qwertqwefsday.eu/ > three dots menu > About Foundkey > click the "I ❤️ Foundkey" button > type MFM and click the "Show preview" <> button

List of MFM functions I tested

These are all the supported functions and different combinations of attributes, and whether they have been confirmed to work. We test text, emoji, and custom emoji.

  • $[center tofu 🐈 :hehe:]

  • $[flip tofu 🐈 :hehe:]

  • $[flip.v tofu 🐈 :hehe:]

  • $[flip.v,h tofu 🐈 :hehe:]

  • $[font.serif tofu 🐈 :hehe:]

  • $[font.monospace tofu 🐈 :hehe:]

  • $[font.cursive tofu 🐈 :hehe:]

  • $[font.fantasy tofu 🐈 :hehe:]

  • $[font.emoji tofu 🐈 :hehe:]

  • $[font.math tofu 🐈 :hehe:]

  • $[blur tofu 🐈 :hehe:]

  • $[rotate tofu 🐈 :hehe:]

  • $[rotate.deg=30 tofu 🐈 :hehe:]

  • $[x2 tofu 🐈 :hehe:]

  • $[x3 tofu 🐈 :hehe:]

  • $[x4 tofu 🐈 :hehe:]

  • $[x2 $[x2 tofu 🐈 :hehe:]]

  • $[x2 $[x2 $[x2 tofu 🐈 :hehe:]]]

  • $[position.x=3 tofu 🐈 :hehe:]

  • $[position.y=5 tofu 🐈 :hehe:]

  • $[position.x=3,y=5 tofu 🐈 :hehe:]

  • $[scale.x=3 tofu 🐈 :hehe:]

  • $[scale.y=5 tofu 🐈 :hehe:]

  • $[scale.x=3,y=5 tofu 🐈 :hehe:]

  • $[fg tofu 🐈 :hehe:]

  • $[fg.color=#fff tofu 🐈 :hehe:]

  • $[bg tofu 🐈 :hehe:]

  • $[bg.color=#fff tofu 🐈 :hehe:]

  • $[jelly tofu 🐈 :hehe:]

  • $[jelly.speed=5s tofu 🐈 :hehe:]

  • $[twitch tofu 🐈 :hehe:]

  • $[twitch.speed=5s tofu 🐈 :hehe:]

  • $[shake tofu 🐈 :hehe:]

  • $[shake.speed=5s tofu 🐈 :hehe:]

  • $[spin tofu 🐈 :hehe:]

  • $[spin.speed=5s tofu 🐈 :hehe:]

  • $[spin.y tofu 🐈 :hehe:]

  • $[spin.y,speed=0.3s tofu 🐈 :hehe:]

  • $[spin.x tofu 🐈 :hehe:]

  • $[spin.x,speed=0.3s tofu 🐈 :hehe:]

  • $[spin.alternate tofu 🐈 :hehe:]

  • $[spin.alternate,speed=0.3s tofu 🐈 :hehe:]

  • $[spin.left tofu 🐈 :hehe:]

  • $[spin.left,speed=0.3s tofu 🐈 :hehe:]

  • $[jump tofu 🐈 :hehe:]

  • $[jump.speed=5s tofu 🐈 :hehe:]

  • $[bounce tofu 🐈 :hehe:]

  • $[bounce.speed=5s tofu 🐈 :hehe:]

  • $[rainbow tofu 🐈 :hehe:]

  • $[rainbow.speed=5s tofu 🐈 :hehe:]

  • $[tada tofu 🐈 :hehe:]

  • $[tada.speed=5s tofu 🐈 :hehe:]

Related https://akkoma.dev/AkkomaGang/akkoma/issues/381 After discussing in <https://akkoma.dev/FoundKeyGang/FoundKey/issues/343> a scrubber-friendly way was discovered for representing the MFM functions in HTML. These are the front-end changes needed for that. This should fix the MFM in Akkoma and provide compatibility for the same MFM functions as Foundkey has. In this PR we: - [x] first we need to add the Foundkey SCSS - I added this in a separate commit so I could add Johan as author. If there's something I should do different, do let me know. - [x] then adapt where needed, including backwards compatibility for posts in the "old" format - [x] make sure the setting for disabling MFM still works - [x] then we need to add JS for the data attr variables - [x] make sure all supported tags are added to `./src/components/emoji_input/suggestor.js` - [x] does it work as expected? - [x] Do the functions display properly, see "Extra notes" below - For custom emojis in `x2`, `x3`, `x4`, `tada`, the sizes that Foundkey uses are used - Otherwise the size that Akkoma already used (38px) is kept - [x] Don't allow going outside of the borders of the status (we use `overflow: hidden;` on the StatusBody now) - other things someone can think of? Broader scope where this PR is part of: - FEP-c16b is a work in progress. It can currently be seen at <https://codeberg.org/fediverse/fep/pulls/382> - The MfmParser needs big adaptions. The work in progress can be seen at <https://codeberg.org/ilja/mfm_parser/pulls/4> - Akkoma backend needs changes, see <https://akkoma.dev/AkkomaGang/akkoma/pulls/823> Extra notes: - Sparkle has not been implemented here. It didn't work before and it requires some extra JS. This is already a strict improvement, and also a very fundamental change over multiple repositories. So it seems better to me, to do sparkle in a separate PR. - We can check MFM on https://genau.qwertqwefsday.eu/ > three dots menu > About Foundkey > click the "I ❤️ Foundkey" button > type MFM and click the "Show preview" `<>` button <details> <summary>List of MFM functions I tested</summary> These are all the supported functions and different combinations of attributes, and whether they have been confirmed to work. We test text, emoji, and custom emoji. - [x] $[center tofu 🐈 :hehe:] - [x] $[flip tofu 🐈 :hehe:] - [x] $[flip.v tofu 🐈 :hehe:] - [x] $[flip.v,h tofu 🐈 :hehe:] - [x] $[font.serif tofu 🐈 :hehe:] - [x] $[font.monospace tofu 🐈 :hehe:] - [x] $[font.cursive tofu 🐈 :hehe:] - [x] $[font.fantasy tofu 🐈 :hehe:] - [x] $[font.emoji tofu 🐈 :hehe:] - [x] $[font.math tofu 🐈 :hehe:] - [x] $[blur tofu 🐈 :hehe:] - [x] $[rotate tofu 🐈 :hehe:] - [x] $[rotate.deg=30 tofu 🐈 :hehe:] - [x] $[x2 tofu 🐈 :hehe:] - [x] $[x3 tofu 🐈 :hehe:] - [x] $[x4 tofu 🐈 :hehe:] - [x] $[x2 $[x2 tofu 🐈 :hehe:]] - [x] $[x2 $[x2 $[x2 tofu 🐈 :hehe:]]] - [x] $[position.x=3 tofu 🐈 :hehe:] - [x] $[position.y=5 tofu 🐈 :hehe:] - [x] $[position.x=3,y=5 tofu 🐈 :hehe:] - [x] $[scale.x=3 tofu 🐈 :hehe:] - [x] $[scale.y=5 tofu 🐈 :hehe:] - [x] $[scale.x=3,y=5 tofu 🐈 :hehe:] - [x] $[fg tofu 🐈 :hehe:] - [x] $[fg.color=#fff tofu 🐈 :hehe:] - [x] $[bg tofu 🐈 :hehe:] - [x] $[bg.color=#fff tofu 🐈 :hehe:] - [x] $[jelly tofu 🐈 :hehe:] - [x] $[jelly.speed=5s tofu 🐈 :hehe:] - [x] $[twitch tofu 🐈 :hehe:] - [x] $[twitch.speed=5s tofu 🐈 :hehe:] - [x] $[shake tofu 🐈 :hehe:] - [x] $[shake.speed=5s tofu 🐈 :hehe:] - [x] $[spin tofu 🐈 :hehe:] - [x] $[spin.speed=5s tofu 🐈 :hehe:] - [x] $[spin.y tofu 🐈 :hehe:] - [x] $[spin.y,speed=0.3s tofu 🐈 :hehe:] - [x] $[spin.x tofu 🐈 :hehe:] - [x] $[spin.x,speed=0.3s tofu 🐈 :hehe:] - [x] $[spin.alternate tofu 🐈 :hehe:] - [x] $[spin.alternate,speed=0.3s tofu 🐈 :hehe:] - [x] $[spin.left tofu 🐈 :hehe:] - [x] $[spin.left,speed=0.3s tofu 🐈 :hehe:] - [x] $[jump tofu 🐈 :hehe:] - [x] $[jump.speed=5s tofu 🐈 :hehe:] - [x] $[bounce tofu 🐈 :hehe:] - [x] $[bounce.speed=5s tofu 🐈 :hehe:] - [x] $[rainbow tofu 🐈 :hehe:] - [x] $[rainbow.speed=5s tofu 🐈 :hehe:] - [x] $[tada tofu 🐈 :hehe:] - [x] $[tada.speed=5s tofu 🐈 :hehe:] </details>
ilja force-pushed use_fep-c16b_formatting_mfm_functions from d1b2e7b51e to aa173b8642 2024-08-04 11:27:40 +00:00 Compare
ilja force-pushed use_fep-c16b_formatting_mfm_functions from aa173b8642 to 7a7fdae4ae 2024-08-04 17:05:26 +00:00 Compare
ilja force-pushed use_fep-c16b_formatting_mfm_functions from 7a7fdae4ae to 3065416c93 2024-08-04 17:10:34 +00:00 Compare
ilja force-pushed use_fep-c16b_formatting_mfm_functions from f12068d6c2 to 56a59e1b55 2024-08-05 15:23:18 +00:00 Compare
ilja added 1 commit 2024-08-10 10:47:06 +00:00
Fix MFM functions x2, x3, and x4
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ba4ae5badb
These now work for the new, FEP-c16b compliant, representation
Nesting also works

It already worked for text and "normal" emoji, but now it also works for custom emoji
ilja added 1 commit 2024-08-10 11:16:21 +00:00
Fix mfm-position and mfm-scale
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
f5f9949253
The `span`'s needed an inline-block for the transform to wrok
I also added an `overflow: hidden;` because these functions can make the text go beyond the borders of the StatusBody
With `overflow: hidden;`, it won't show outside of the borders
ilja added 1 commit 2024-08-10 11:57:19 +00:00
MFM make all supported tags suggested
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
3210873d7f
When typing MFM, a sugestor drop-down appears so you can see and/or choose what MFM function to use
The new MFM functions we support have now also been added
ilja changed title from WIP: Use FEP-c16b: Formatting MFM functions to Use FEP-c16b: Formatting MFM functions 2024-08-10 18:49:22 +00:00
ilja changed title from Use FEP-c16b: Formatting MFM functions to WIP: Use FEP-c16b: Formatting MFM functions 2024-08-11 12:38:51 +00:00
ilja changed title from WIP: Use FEP-c16b: Formatting MFM functions to Use FEP-c16b: Formatting MFM functions 2024-08-11 12:50:19 +00:00
ilja force-pushed use_fep-c16b_formatting_mfm_functions from dcd09d38e8 to 6666a273a4 2024-08-11 16:11:50 +00:00 Compare
Author
Contributor

found a bug ☹️ fixed what we can, upstream issue created where we can't

https://mk.absturztau.be/notes/9vdb32gycp0700sc

"_misskey_content": "<center>$[fg.color=ffaa77 <b>MISSKEY FLAVORED</b>]\n<b>$[fg.color=ffaaaa $[x2 FEDI ⭐️ VERSE]]</b></center>"
  1. The newline doesn't show on my instance for some reason.
  2. The colours don't work. Apparently it uses ffaa77, but I think I expect the colour values to start with #. Need to check what's the correct way(s) to do. Only without # is valid for value for color, this is now fixed
~~found a bug ☹️~~ fixed what we can, upstream issue created where we can't https://mk.absturztau.be/notes/9vdb32gycp0700sc ``` "_misskey_content": "<center>$[fg.color=ffaa77 <b>MISSKEY FLAVORED</b>]\n<b>$[fg.color=ffaaaa $[x2 FEDI ⭐️ VERSE]]</b></center>" ``` 1. [x] The newline doesn't show on my instance for some reason. * Is a bug in EarmarkParser, so I don't think it should be fixed here, see <https://github.com/RobertDober/earmark_parser/issues/158>. I wasn't able to work-around it by trying different versions of the dependency. * I also made an issue on the Akkoma issue tracker so that we know about it, https://akkoma.dev/AkkomaGang/akkoma/issues/829 2. [x] ~~The colours don't work. Apparently it uses `ffaa77`, but I think I expect the colour values to start with `#`. Need to check what's the correct way(s) to do.~~ Only without `#` is valid for value for `color`, this is now fixed
ilja added 1 commit 2024-08-18 13:54:22 +00:00
Don't require # in the data-mfm-color attribute
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
25681cf5f6
For colour in MFM attributes, we expected a `#`, but that's apparently wrong. The BE
translates the `color` attribute in `$[fg.color=000 text]` into `data-mfm-color=000`.
But for the SCSS to work, we need to put it in the style attribute as `--mfm-color: #000`.

Generally we just add the attribute value as-is in the `style` attribute, but now we
have a special exception for color so we add a `#` before the value.
Oneric reviewed 2024-08-25 01:21:11 +00:00
Oneric left a comment
Member

I continue to think it’d be best for API users to perform the “data → style variables” transformation in the backend, so any frontend/app can easily support MFM rendering by just including a static CSS file. CSS rendering is a lower bar to clear than running scripts to parse and transform each post (and then still apply CSS rendering)

I continue to think it’d be best for API users to perform the “data → style variables” transformation in the backend, so any frontend/app can easily support MFM rendering by just including a static CSS file. CSS rendering is a lower bar to clear than running scripts to parse and transform each post (and then still apply CSS rendering)
@ -0,0 +69,4 @@
*/
.emoji {
--mfm-emoji-zoom-size: 2.63;
}
Member

I think the whole emoji size scaling setup is overly complicated. Just setting --mfm-emoji-zoom-size: 2.63; etc as here in all relevant cases and using this with a default of 1.0 directly in the base emoji height definition would achieve the same effect as now but avoid manually overriding height directly and --nested-base-emoji-size for some MFM effects.

However, while i appreciate the effort which went into preserving Akkoma’s old emoji scaling exactly (except for nested scaling which previously was a noop), this scaling behaviour is not compatible with Foundkey, iceshrimp and likely all other keys and imho leads to a jarring discrepancy as emoji get scaled noticeable more than text. Foundkey and IceShrimp set the emoji height to 2em instead of a fixed pixel value which means they’ll get automatically be scaled together with and by the same amount as text without any emoji-specific scaling logic. Imho we should adopt this too; improving portability and simplifying our logic at the same time.

I think the whole emoji size scaling setup is overly complicated. Just setting `--mfm-emoji-zoom-size: 2.63;` etc as here in all relevant cases and using this with a default of `1.0` directly in the base emoji `height` definition would achieve the same effect as now but avoid manually overriding `height` directly and `--nested-base-emoji-size` for some MFM effects. However, while i appreciate the effort which went into preserving Akkoma’s old emoji scaling exactly *(except for nested scaling which previously was a noop)*, this scaling behaviour is not compatible with Foundkey, iceshrimp and likely all other keys and imho leads to a jarring discrepancy as emoji get scaled noticeable more than text. Foundkey and IceShrimp set the emoji height to `2em` instead of a fixed pixel value which means they’ll get automatically be scaled together with and by the same amount as text without any emoji-specific scaling logic. Imho we should adopt this too; improving portability and simplifying our logic at the same time.
Author
Contributor

set the emoji height to 2em instead of a fixed pixel value

Yes! I didn't understand why I needed extra CSS for emoji while Foundey didn't ^^' Using em works perfectly, thx!

One problem I saw with this, as you say, *key uses 2em. But Akkoma uses 38px, which corresponds to ~2.9px. So that means that we'd have smaller emoji than what people are used to on Akkoma-fe. I see two options

  • We set emoji at 2em, and people have to live with it (personally I prefer them a bit bigger)
  • We keep 38px for emoji, but when a zoom (x2, x3, x4, tada) is used, we override to --emoji-size: 2em;. In normal situations, emoji will be 38px as they are now. When a zoom is used, the emoji will be e.g. 2em * 200%. For tada, it will start at 2em, so smaller than "normal", but then it grows bigger bc that's what tada does.

When I try, this looks OK for me. It may cause things to be slightly off for things like mfmArt, but if we want to be completely compatible with the most advanced mfmArt, we have to change a lot more I'm afraid. So the question then becomes how far we want to go with that.

I now pushed a new commit with the second option, because it looks best to me, but it can still be changed if needed.

> set the emoji height to 2em instead of a fixed pixel value Yes! I didn't understand why I needed extra CSS for emoji while Foundey didn't ^^' Using `em` works perfectly, thx! One problem I saw with this, as you say, *key uses 2em. But Akkoma uses 38px, which corresponds to ~2.9px. So that means that we'd have smaller emoji than what people are used to on Akkoma-fe. I see two options * We set emoji at 2em, and people have to live with it (personally I prefer them a bit bigger) * We keep 38px for emoji, but when a zoom (x2, x3, x4, tada) is used, we override to `--emoji-size: 2em;`. In normal situations, emoji will be 38px as they are now. When a zoom is used, the emoji will be e.g. `2em * 200%`. For tada, it will start at `2em`, so smaller than "normal", but then it grows bigger bc that's what tada does. When I try, this looks OK for me. It may cause things to be slightly off for things like mfmArt, but if we want to be completely compatible with the most advanced mfmArt, we have to change a lot more I'm afraid. So the question then becomes how far we want to go with that. I now pushed a new commit with the second option, because it looks best to me, but it can still be changed if needed.
Member

i was thinking of continuing to retain the current base size for non-MFM posts, but use 2em for MFM posts only.
This way scaling remains striaghtforward and we’re more compatible while the majority of posts (not-MFM) doesn't change at all

i was thinking of continuing to retain the current base size for non-MFM posts, but use `2em` for MFM posts only. This way scaling remains striaghtforward and we’re more compatible while the majority of posts (not-MFM) doesn't change at all
Author
Contributor

That one has crossed my mind too, but also has its problems (and worse imo).

From a code-complexity perspective; We now need a way for css to know what posts are mfm and not. It's doable, we can add a class somewhere with what content they were written in (or at least that it's MFM). But that's more complexity than what I did now (just one extra line in the css that already handles the zoom), so not an advantage in that regard, on the contrary.

It also means that input method now has an effect on the end result. But input method should purely be a client thing imo, transforming input into a proper representation. With MFM we couldn't do that, hence the work that this PR is part of. Bringing back the requirenment for knowing the input method and doing special handling goes against the "raison d'être" of this work for me.

There's also the fact that it may not be obvious to people why a custom emoji is smaller in some cases and bigger in others. Not all posts who are marked as having MFM are always MfmArt. So in those cases you'd have a perfectly normal-looking post, but suddenly the emoji have a different size than what people expect. This is internally inconsistent and I fear this will bring more confusion.

That one has crossed my mind too, but also has its problems (and worse imo). From a code-complexity perspective; We now need a way for css to know what posts are mfm and not. It's doable, we can add a class somewhere with what content they were written in (or at least that it's MFM). But that's more complexity than what I did now (just one extra line in the css that already handles the zoom), so not an advantage in that regard, on the contrary. It also means that input method now has an effect on the end result. But input method should purely be a client thing imo, transforming input into a proper representation. With MFM we couldn't do that, hence the work that this PR is part of. Bringing back the requirenment for knowing the input method and doing special handling goes against the "raison d'être" of this work for me. There's also the fact that it may not be obvious to people why a custom emoji is smaller in some cases and bigger in others. Not all posts who are marked as having MFM are always MfmArt. So in those cases you'd have a perfectly normal-looking post, but suddenly the emoji have a different size than what people expect. This is internally inconsistent and I fear this will bring more confusion.
Member

From a code-complexity perspective; We now need a way for css to know what posts are mfm and not

If it wasn’t dropped as part of this change we already have that via the .mfm class. In fact this change is part of the client-side overrides I’m applying atm to make MFM post behave better.

current MFM CSS overrides for reference
    /* Slow default down until Akkoma parses parameters again */
    ._mfm_spin_ {
        animation: mfm-spin 2.0s linear infinite !important;
    }
    
    /* Nested Tags use calc(var(--mfm-zoom-size) / 2 + 50%)
     * With zoom-size being:
     *  - x4: 600%
     *  - x3: 400%
     *  - x2: 200%
     */
    ._mfm_x2_ ._mfm_x4_,
    ._mfm_x3_ ._mfm_x4_,
    ._mfm_x4_ ._mfm_x4_ {
        font-size: 350%;
    }
    ._mfm_x2_ ._mfm_x3_,
    ._mfm_x3_ ._mfm_x3_,
    ._mfm_x4_ ._mfm_x3_ {
        font-size: 250%;
    }
    ._mfm_x2_ ._mfm_x2_,
    ._mfm_x3_ ._mfm_x2_,
    ._mfm_x4_ ._mfm_x2_ {
        font-size: 150%;
    }
    
    .mfm .emoji /*img*/ {
        height: 2em !important;
        vertical-align: middle;/**/
    }

It also means that input method now has an effect on the end result.

Input methods already have an effect on the end result, e.g. MFM is rendered as an inline block, line spacing differs between MFM,Markdown and BBCode,plain text, plain text quotes get coloured while in Markdown and MFM it gets shifted, set in faint text /Or italics atm) and a bar is added, etc

Each input method is a different typeset language and to get the same result across different input methods, different input is required (if possible at all).
MFM in particular comes with stricter expectations on what constitutes a correct display and is defined by *key instances. One of those requirements being 2em-sized emoji.

> From a code-complexity perspective; We now need a way for css to know what posts are mfm and not If it wasn’t dropped as part of this change we already have that via the `.mfm` class. In fact this change is part of the client-side overrides I’m applying atm to make MFM post behave better. <details> <summary>current MFM CSS overrides for reference</summary> ```css /* Slow default down until Akkoma parses parameters again */ ._mfm_spin_ { animation: mfm-spin 2.0s linear infinite !important; } /* Nested Tags use calc(var(--mfm-zoom-size) / 2 + 50%) * With zoom-size being: * - x4: 600% * - x3: 400% * - x2: 200% */ ._mfm_x2_ ._mfm_x4_, ._mfm_x3_ ._mfm_x4_, ._mfm_x4_ ._mfm_x4_ { font-size: 350%; } ._mfm_x2_ ._mfm_x3_, ._mfm_x3_ ._mfm_x3_, ._mfm_x4_ ._mfm_x3_ { font-size: 250%; } ._mfm_x2_ ._mfm_x2_, ._mfm_x3_ ._mfm_x2_, ._mfm_x4_ ._mfm_x2_ { font-size: 150%; } .mfm .emoji /*img*/ { height: 2em !important; vertical-align: middle;/**/ } ``` </details> > It also means that input method now has an effect on the end result. Input methods already have an effect on the end result, e.g. MFM is rendered as an inline block, line spacing differs between MFM,Markdown and BBCode,plain text, plain text quotes get coloured while in Markdown and MFM it gets shifted, set in faint text /Or italics atm) and a bar is added, etc Each input method is a different typeset language and to get the same result across different input methods, different input is required *(if possible at all)*. MFM in particular comes with stricter expectations on what constitutes a *correct* display and is defined by \*key instances. One of those requirements being `2em`-sized emoji.
Author
Contributor

I should maybe rephrase myself. We get an object who has a content field. It also has a source field. Currently we use the source field, and that causes problems. This whole excercise here is about making it so that the content can be used without requiring the source field.

Afaik, the differences you mention don't have anything to do with the source (i.e. stated input method) field at all, they are purely derived from the content. The only exception is MFM, and that's what this is trying to fix.

MFM in particular comes with stricter expectations on what constitutes a correct display and is defined by *key instances. One of those requirements being 2em-sized emoji.

I certainly do not have the expectation of emoji to suddenly look different, and I very much believe it will only cause more confusion. Emoji are federated just like any one else federates them, so there's no special expectation there. There's is also no specific mention of 2em on https://misskey-hub.net/en/docs/for-users/features/mfm/

Besides, if that's really the case to make, that the content should look like it does on Misskey; how far should this be taken? Because there's more than just "emoji are 2em size". Should the text font be different? Should the spacings be different? Should we render the spacing differend? Heck, should the width of the content be changed? And so on... If yes, then we dissagree on a very fundamental level which I do not see how to resolve.

I should maybe rephrase myself. We get an object who has a `content` field. It also has a `source` field. Currently we use the `source` field, and that causes problems. This whole excercise here is about making it so that the `content` can be used without requiring the `source` field. Afaik, the differences you mention don't have anything to do with the `source` (i.e. stated input method) field at all, they are purely derived from the content. The only exception is MFM, and that's what this is trying to fix. > MFM in particular comes with stricter expectations on what constitutes a correct display and is defined by *key instances. One of those requirements being 2em-sized emoji. I certainly do not have the expectation of emoji to suddenly look different, and I very much believe it will only cause more confusion. Emoji are federated just like any one else federates them, so there's no special expectation there. There's is also no specific mention of `2em` on https://misskey-hub.net/en/docs/for-users/features/mfm/ Besides, if that's really the case to make, that the content should look like it does on Misskey; how far should this be taken? Because there's more than just "emoji are `2em` size". Should the text font be different? Should the spacings be different? Should we render the spacing differend? Heck, should the width of the content be changed? And so on... If yes, then we dissagree on a very fundamental level which I do not see how to resolve.
Author
Contributor

Maybe a more important question; Do you consider this a blocking issue? If not, I'd like to keep it for now, as I do consider it a strict improvement regardless, and then see what people think.

Maybe a more important question; Do you consider this a blocking issue? If not, I'd like to keep it for now, as I do consider it a strict improvement regardless, and then see what people think.
ilja added 1 commit 2024-11-01 13:27:33 +00:00
Improve how scaling is done
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
177d96f977
During code review a much better way was pointed out to do the emoji scaling, by using `em`.

*key uses 2em for emoji, which is smaller than Akkoma has. I now kept the 38px for Akkoma,
but when "zoom" (ie x2, x3, x4, tada) happens, we set to 2em and zoom from there.
Author
Contributor

I continue to think it’d be best for API users to perform the “data → style variables” transformation in the backend, so any frontend/app can easily support MFM rendering by just including a static CSS file. CSS rendering is a lower bar to clear than running scripts to parse and transform each post (and then still apply CSS rendering)

This feels wrong to me. The back-end provides what to show, but how to exactly implement this, is then up to the front-end. In this case, it may by using var(), but another front-end may want to do something different. Maybe they use a different technology, or maybe some day in the future data-* attributes become easier to work with and front-ends don't need this any more. Other problems I see are where to do this. Are we gonna store the style variables in the database? That means we're also federating it. What about scrubbers, won't they give problems? Or is this purely when a post is fetched. That means we have to run over each post in the backend when it's fetched, and implement a parser there. It seems like moving the problem from one side to another, while breaking responsabilities, for very few gain imo. Especially since sparkle (which isn't implemented yet, but I'd like to keep that for a future PR) needs something more advanced regardles.

> I continue to think it’d be best for API users to perform the “data → style variables” transformation in the backend, so any frontend/app can easily support MFM rendering by just including a static CSS file. CSS rendering is a lower bar to clear than running scripts to parse and transform each post (and then still apply CSS rendering) This feels wrong to me. The back-end provides what to show, but how to exactly implement this, is then up to the front-end. In this case, it may by using `var()`, but another front-end may want to do something different. Maybe they use a different technology, or maybe some day in the future data-* attributes become easier to work with and front-ends don't need this any more. Other problems I see are where to do this. Are we gonna store the style variables in the database? That means we're also federating it. What about scrubbers, won't they give problems? Or is this purely when a post is fetched. That means we have to run over each post in the backend when it's fetched, and implement a parser there. It seems like moving the problem from one side to another, while breaking responsabilities, for very few gain imo. Especially since sparkle (which isn't implemented yet, but I'd like to keep that for a future PR) needs something more advanced regardles.
Member

This feels wrong to me. The back-end provides what to show, but how to exactly implement this, is then up to the front-end.

The backend provides safe HTML content to show and frontends just display the received HTML. data attributes don't actually tell the frontend what display is expected and require MFM-specific logic to be implement in every frontend and app.
Effectively this means MFM won't ever display correctly outside akkoma-fe.

Transforming MFM data attributes into CSS variables in the backend on the other hand is simple and we already process HTML anyway to make it safe. Frontends/Apps then only need to include a simple static CSS file. If they also contain their own safety stripping logic they need to make sure CSS variables are retained, but CSS variables are safe anyway and this variable mechanism could be shared with other more powerful source formats.
Chances for correct MFM display in multiple frontends/apps seem higher this way imho.

Note: sparkle can also be implemented as a static effect, it’s just not a straightforward copy from current Misskey since Miskkey adds and removes each sparkle node dynamically atm. (Instead of adding and removing nodes, just use a fixed amount and hide/unhide them during animation)

Taking “how to exactly implement this, is then up to the front-end” further would mean all frontends completely ignore HTML content and create their own display directly from the provided post source.

> This feels wrong to me. The back-end provides what to show, but how to exactly implement this, is then up to the front-end. The backend provides safe HTML content to show and frontends just display the received HTML. `data` attributes don't actually tell the frontend what display is expected and require MFM-specific logic to be implement in every frontend and app. Effectively this means MFM won't ever display correctly outside akkoma-fe. Transforming MFM data attributes into CSS variables in the backend on the other hand is simple and we already process HTML anyway to make it safe. Frontends/Apps then only need to include a simple static CSS file. If they also contain their own safety stripping logic they need to make sure CSS variables are retained, but CSS variables are safe anyway and this variable mechanism could be shared with other more powerful source formats. Chances for correct MFM display in multiple frontends/apps seem higher this way imho. Note: `sparkle` *can* also be implemented as a static effect, it’s just not a straightforward copy from current Misskey since Miskkey adds and removes each sparkle node dynamically atm. *(Instead of adding and removing nodes, just use a fixed amount and hide/unhide them during animation)* Taking *“how to exactly implement this, is then up to the front-end”* further would mean all frontends completely ignore HTML content and create their own display directly from the provided post source.
Author
Contributor

data attributes don't actually tell the frontend what display is expected

Yes it does, that's what FEP-c16b is for. I linked to it in the description.

Effectively this means MFM won't ever display correctly outside akkoma-fe.

Providing the variables in style doesn't change that.

Transforming MFM data attributes into CSS variables in the backend on the other hand is simple and we already process HTML anyway to make it safe

It's simple on the front-end, and HTML is already processed there too for e.g. custom emoji, or names of people who are tagged. For backend I'm not so sure that it's simple. Currently (on main) the MFM attributes don't work. We change the content of the source property to change the HTML, and at one time, this worked, also for attributes. But then a scrubber was changed, and suddenly it didn't get through any more. I'm not sure how it all flows in the back-end, but knowing that, I'm not so sure that it really is easier on the back-end.

Taking “how to exactly implement this, is then up to the front-end” further would mean all frontends completely ignore HTML content and create their own display directly from the provided post source.

That's false. The content is a "textual representation of the Object". It describes how something should look (using HTML by default, extended with FEP-c16b for those who choose to implement FEP-c16b, still allowing a certain degree of freedom for the things who aren't specified). We can disagree on practical considerations for implementers, but this is what it is.

Don't get me wrong, I do agree that adding the variables in style can make things slightly easier on other front-ends. But I still also feel it's breaking responsabilities between front-end and back-end, and that simply doesn't sit right with me. Especially for a first implementation. It comes at a cost, and I'm not convinced yet that it's worth it. The way I see it; We have something that works now, if it turns out that it's indeed better to have this done on the back-end (as well?) then it can still be done later by whoever wants to implement that. But if we do it now, and it turns out to give unexpected problems, then going back is way harder because that will be a breaking change. Therefor I would like to keep this as it is now.

> `data` attributes don't actually tell the frontend what display is expected Yes it does, that's what [FEP-c16b](https://codeberg.org/fediverse/fep/src/branch/main/fep/c16b/fep-c16b.md) is for. I linked to it in the description. > Effectively this means MFM won't ever display correctly outside akkoma-fe. Providing the variables in `style` doesn't change that. > Transforming MFM data attributes into CSS variables in the backend on the other hand is simple and we already process HTML anyway to make it safe It's simple on the front-end, and HTML is already processed there too for e.g. custom emoji, or names of people who are tagged. For backend I'm not so sure that it's simple. Currently (on main) the MFM attributes don't work. We change the content of the `source` property to change the HTML, and at one time, this worked, also for attributes. But then a scrubber was changed, and suddenly it didn't get through any more. I'm not sure how it all flows in the back-end, but knowing that, I'm not so sure that it really is easier on the back-end. > Taking “how to exactly implement this, is then up to the front-end” further would mean all frontends completely ignore HTML content and create their own display directly from the provided post source. That's false. The `content` is a "[textual representation of the Object](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-content)". It describes how something should look (using HTML by default, extended with FEP-c16b for those who choose to implement FEP-c16b, still allowing a certain degree of freedom for the things who aren't specified). We can disagree on practical considerations for implementers, but this is what it is. Don't get me wrong, I do agree that adding the variables in `style` can make things slightly easier on other front-ends. But I still also feel it's breaking responsabilities between front-end and back-end, and that simply doesn't sit right with me. Especially for a first implementation. It comes at a cost, and I'm not convinced yet that it's worth it. The way I see it; We have something that works now, if it turns out that it's indeed better to have this done on the back-end (as well?) then it can still be done later by whoever wants to implement that. But if we do it now, and it turns out to give unexpected problems, then going back is way harder because that will be a breaking change. Therefor I would like to keep this as it is now.

ok so fun fact part of the reason mfm support in current stable is so patchy is that *oma supports pure html posting, which means our scrubber needs to be very resilient to not allow shenanigans through

which means the amount of processing we can actually do on the backend safely is limited - I actually removed some functionality after it was shown to allow bad remote html through because the style attribute is mostly unbound in flexibility

ok so fun fact part of the reason mfm support in current stable is so patchy is that *oma supports pure html posting, which means our scrubber needs to be very resilient to not allow shenanigans through which means the amount of processing we can actually do on the backend safely is limited - I actually removed some functionality after it was shown to allow bad remote html through because the style attribute is mostly unbound in flexibility
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u use_fep-c16b_formatting_mfm_functions:ilja-use_fep-c16b_formatting_mfm_functions
git checkout ilja-use_fep-c16b_formatting_mfm_functions
Sign in to join this conversation.
No description provided.