Conversion from block mark-up to/from Markdown

Aperta
#11 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
30/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Tranquilla
Stack tecnologico
markdown, php
Ambito
cli, content

Direzione di ricerca

Start by reviewing the related wp-cli/ideas issue and the linked wxr converter to understand existing approaches to block markup conversion. A complete result would define the supported export and import scope, configurable Markdown handling, standard block handlers, and behavior for unknown blocks.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

command:block enhancement scope:distribution

Feature Request

Describe your use case and the problem you are facing

Export from existing WordPress installation's Gutenberg pages to Markdown for interop with other content engines or to LLMs which tend to like Markdown. Import would also be great. My usecase is to convert to Markdown the block markup syntax strings found in WXR files exported from an existing WP installation.

Describe the solution you'd like

Versatile / configurable export from block markup to Markdown. Custom attributes can be optionally exported via CommonMark Directive syntax which already has support in remark. Even if conversion is not 100% faithful, it is already useful: e.g. for making existing WordPress content consumable in good form for RAG / LLMs.

There are a lot of various existing markdown plugins for WordPress, but there is a need for a well-tested official one (which will be maintained, currently maintenance is also fragmented, there are plenty of abandoned exporters), but versatile one which can be scripted, so it's a good fit for CLI command, in my opinion.

Ideally, there must be handlers for standard block types, and some catch-all for optionally exporting verbatim HTML for the blocks which do not have registered markdown converter. Having some HTML in Markdown is also fine, as the user can then postproc the markdown files with remark/rehype pipelines.

IMO such exporter should accept that there does not exist a single right way to export to Markdown so some configurability is to be expected, as users may want to get different flavors of Markdown (e.g. both preserving the text color as Directives, or just dropping it altogether are good and useful, depending on the user's usecase).

Related:

For now, I had to roll my own https://github.com/vadimkantorov/wxr for exporting block markup from WXR to HTML files (preserving attributes), and then for converting them to Markdown (and also allowing some custom URL / image URL postprocessing / downloading the linked images etc). In this converter I'm often representing unknown blocks as:

---
blah blah some info about a block without a standard way to represent in Markdown (not frontmatter)
---

more markdown

So essentially using a pair of --- dividers to enclose some block info. Then a custom remark/rehype pipeline could interpret / render these in a custom way if a user desires so.

Lingua principale
PHP
Stelle
2
Fork
1
Merge medio
6m
PR unite (30g)
2

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.