Skip to content

Commit

Permalink
Feat: 给未配置语言的代码块新增一个默认样式 (#560)
Browse files Browse the repository at this point in the history
  • Loading branch information
LuRenJiasWorld committed Apr 11, 2023
1 parent 47cbf8b commit aa87b08
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 40 deletions.
21 changes: 21 additions & 0 deletions assets/FrontStyle/FrontStyle.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@charset "UTF-8";

// 避免主题或 WordPress 默认样式导致多行代码自动换行
// 只用于 Fallback,如果主题有自带样式,则尊重主题样式
pre code,
pre code.wp-block-code,
pre code.wp-editormd-codeblock {
// Copied from prism.css as a fallback style
// Issue ref: https://github.com/LuRenJiasWorld/WP-Editor.md/issues/560
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-size: 1em;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
tab-size: 4;
hyphens: none;
}
:
21 changes: 0 additions & 21 deletions assets/FrontStyle/frontstyle.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/App/WPMarkdownParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public function _doFencedCodeBlocks_callback($matches) {
break;
//代码块
default:
$classes = array();
$classes = array("wp-editormd-codeblock");
$langname = "";
if ($classname != "") {
if ($classname[0] == ".") {
Expand Down
32 changes: 14 additions & 18 deletions webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ module.exports = {
entry: {
"assets/Editormd/editormd": "./assets/Editormd/src/editormd.js",
"assets/Editormd/editormd.min.css": "./assets/Editormd/scss/editormd.scss",
"assets/Editormd/editormd.preview.min.css":
"./assets/Editormd/scss/editormd.preview.scss",
"assets/Editormd/editormd.preview.min.css": "./assets/Editormd/scss/editormd.preview.scss",
"assets/Config/editormd": "./assets/Config/editormd.js",
"assets/FrontStyle/frontstyle": "./assets/FrontStyle/frontstyle.js",
"assets/FrontStyle/FrontStyle": "./assets/FrontStyle/FrontStyle.js",
"assets/FrontStyle/FrontStyle.min.css": "./assets/FrontStyle/FrontStyle.scss",
},
output: {
filename: "[name].min.js",
Expand Down Expand Up @@ -173,15 +173,18 @@ module.exports = {
options: {
workers: 2,
workerParallelJobs: 50,
workerNodeArgs: ['--max-old-space-size=1024'],
name: 'js-builders'
}
}
]
workerNodeArgs: ["--max-old-space-size=1024"],
name: "js-builders",
},
},
],
},
{
test: /\.scss$/,
include: [path.resolve(__dirname, "assets/Editormd/scss")],
include: [
path.resolve(__dirname, "assets/Editormd/scss"),
path.resolve(__dirname, "assets/FrontStyle"),
],
use: [
{
loader: MiniCssExtractPlugin.loader,
Expand All @@ -207,10 +210,9 @@ module.exports = {
],
},
{
test: /\.(css|scss|sass)$/,
test: /\.css$/,
include: [
path.resolve(__dirname, "assets/Config"),
path.resolve(__dirname, "assets/FrontStyle"),
],
use: [
{
Expand All @@ -227,13 +229,7 @@ module.exports = {
options: {
postcssOptions: {
plugins: [require("autoprefixer")({})],
}
},
},
{
loader: "sass-loader",
options: {
implementation: require("node-sass"),
},
},
},
],
Expand Down

0 comments on commit aa87b08

Please sign in to comment.