admin管理员组文章数量:1122846
I plan to publish latex code on WordPress. My VPS has a full installation of texlive and my WordPress will call xelatex or pdflatex to generate pdf, and my WordPress will also call pandoc to generate html.
I am new to WordPress (plugin) development, but I guess my workflow can be implemented as a custom post.
register_post_type( 'latex_page',
array('supports'=> array( 'title', 'editor'),
...
));
This piece of code adds 'editor' to the supports
option, and users will write their latex code in the WordPress editor.
But the WordPress editor by default is Gutenberg editor. Its block style is completely useless for a latex file. Even if I switch to the classic editor, the <b>
, <i>
buttons and the like are not necessary.
What's more, the edit page displays an "Add Media" button. The logic of the "Add Media" button doesn't work with Latex. Latex uses the syntax like \includegraphics[width=1em]{github.png}
, but the "Add Media" button adds the code <a href="github.png"><img src="github.png></a>
. To avoid complexity, for now I do not want to allow users to use includegraphics.
I am a mathematician. So by definition, what is the WordPress editor? What content does it suppose to edit?
I figure rather than disabling everything in the feature-rich editor, why don't I just use a plain text custom field to hold latex code?
I plan to publish latex code on WordPress. My VPS has a full installation of texlive and my WordPress will call xelatex or pdflatex to generate pdf, and my WordPress will also call pandoc to generate html.
I am new to WordPress (plugin) development, but I guess my workflow can be implemented as a custom post.
register_post_type( 'latex_page',
array('supports'=> array( 'title', 'editor'),
...
));
This piece of code adds 'editor' to the supports
option, and users will write their latex code in the WordPress editor.
But the WordPress editor by default is Gutenberg editor. Its block style is completely useless for a latex file. Even if I switch to the classic editor, the <b>
, <i>
buttons and the like are not necessary.
What's more, the edit page displays an "Add Media" button. The logic of the "Add Media" button doesn't work with Latex. Latex uses the syntax like \includegraphics[width=1em]{github.png}
, but the "Add Media" button adds the code <a href="github.png"><img src="github.png></a>
. To avoid complexity, for now I do not want to allow users to use includegraphics.
I am a mathematician. So by definition, what is the WordPress editor? What content does it suppose to edit?
I figure rather than disabling everything in the feature-rich editor, why don't I just use a plain text custom field to hold latex code?
Share Improve this question edited Jun 19, 2024 at 6:50 Gqqnbig asked Jun 19, 2024 at 6:41 GqqnbigGqqnbig 1651 gold badge1 silver badge7 bronze badges1 Answer
Reset to default 1The editor enables you to enter either plain text or HTML content to a post/page body. The content is saved to post_content
column on the wp_post
database table.
When rendering the content WordPress runs it through a few filters to automatically add <p>
tags, capitalize P in Wordpress, etc. If the content contains shortcode markup (i.e. square brackets stuff) or block related HTML comments, then WordPress will parse those into HTML - assuming the shortcodes and blocks have been registered properly.
Yes, if you want more control, you can register a custom metabox (or a block) with a plain textarea for the latex code. You can even go wild and disable the default editor completely, register a custom metabox with a textarea named "content" and have the latex code saved automatically to the post_content
column instead of a post meta field.
本文标签: Editor or custom field for Latex source code page
版权声明:本文标题:Editor or custom field for Latex source code page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736303341a1931850.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论