Descripción
This plugin extends the Code block in WordPress core to add syntax highlighting which is rendered on the server. Pre-existing Code blocks on a site are automatically extended to include syntax highlighting. Doing server-side syntax highlighting eliminates the need to enqueue any JavaScript on the frontend (e.g. Highlight.js or Prism.js) and this ensures there is no flash of unhighlighted code (FOUC?). Reducing script on the frontend improves frontend performance and it also allows for the syntax highlighted code to appear properly in AMP pages as rendered by the official AMP plugin (see also ampproject/amp-wp#972) or when JavaScript is turned off in the browser.
In addition to not adding any JavaScript to the frontend, the stylesheets needed for styling the Code block will only be added to the page if there is a Code block present. The stylesheets are added inline when the Code block is rendered, ensuring that they do not block rendering of any content higher in the page. If stylesheets fail to load for any reason, the block simply renders without styling, with one key exception: highlighted lines are wrapped in mark
elements so they’ll get highlighted regardless, including in RSS Feeds and posts syndicated in email (as long as the mark
element is supported in the client).
This extended Code block uses language auto-detection to add syntax highlighting, but you can override the language in the block’s settings sidebar. (There is currently no syntax highlighting of the Code block in the editor.) The plugin supports all programming languages that highlight.php supports (being a port of highlight.js). The Code block also is extended to support specifying the aforementioned highlighted lines. There is also a checkbox for whether to show line numbers on the frontend (with the numbers being non-selectable). Lastly, given inconsistencies across themes as to whether lines in a Code block should be wrapped, this plugin adds styling to force them to no-wrap by default, with a checkbox to opt-in to wrapping when desired.
Para uso avanzado, por favor ve la wiki del plugin.
Este plugin es desarrollado en GitHub. Ve la lista de problemas actuales con el plugin. Por favor, siéntete libre de agregar cualquier otro problema o solicitud que puedas tener. Las peticiones de validación son bienvenidas.
Créditos
This is a fork of Code Syntax Block by Marcus Kazmierczak (mkaz), which is also available on WordPress.org. Copyright (c) 2018 Marcus Kazmierczak. Licensed under GPL 2.0 or later.
highlight.php es lanzado bajo la licencia BSD 3-Clause. Copyright © 2006-2013, Ivan Sagalaev (maniac@softwaremaniacs.org), highlight.js (autor original). Copyright © 2013, Geert Bergman (geert@scrivo.nl), highlight.php
Capturas
Los bloques de código se pueden agregar del modo usual, anulando opcionalmente el idioma auto-detectado. También especifica cualquier línea que deba ser destacada, si se deben mostrar los números de las línea, y que líneas deben ser cerradas. The Code block renders with syntax highlighting on the frontend without any JavaScript enqueued. Stylesheets are added only when block is on the page.
Reseñas
Colaboradores y desarrolladores
Este software es de código abierto. Las siguientes personas han contribuido a este plugin.
Colaboradores"Syntax-highlighting Code Block (with Server-side Rendering)" ha sido traducido a 8 idiomas locales. Gracias a los traductores por sus contribuciones.
Traduce "Syntax-highlighting Code Block (with Server-side Rendering)" a tu idioma.
¿Interesado en el desarrollo?
Revisa el código, echa un vistazo al repositorio SVN o suscríbete al registro de desarrollo por RSS.
Registro de cambios
Para la bitácora de cambios del plugin, por favor, consulta la página de versiones en GitHub.