微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

括号无法在hexo博客中正确显示

如何解决括号无法在hexo博客中正确显示

我试图使用Github页面和hexo建立个人博客。我正在使用主题主题。但是,无法在hexo博客中正确显示代码区域中的方括号。而是显示为{。我不确定我做了什么更改。 现在的代码如下所示。

public class Client {
    public static void main() {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();        
        DataOutputStream dos = new DataOutputStream(baos);
        dos.writeInt(1);

我不熟悉前端问题,而且我不知道自己做了什么更改。我曾经怀疑/node_modules/marked/lib/marked.js出了问题。但是,我去https://github.com/markedjs/marked/tree/master/lib下载了一个新的。它仍然不起作用。有人可以帮我吗?

marked.js中的内联部分

  var inline = {
    escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,// escape: /^\\([`*\[\]()#$+\-.!_>])/,autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url: noopTest$1,tag: '^comment' + '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
    + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
    + '|^<\\?[\\s\\S]*?\\?>' // processing instruction,e.g. <?PHP ?>
    + '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration,e.g. <!DOCTYPE html>
    + '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>',// CDATA section
    link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,reflinkSearch: 'reflink|nolink(?!\\()',strong: {
      start: /^(?:(\*\*(?=[*punctuation]))|\*\*)(?![\s])|__/,// (1) returns if starts w/ punctuation
      middle: /^\*\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*\*$|^__(?![\s])((?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?)__$/,endAst: /[^punctuation\s]\*\*(?!\*)|[punctuation]\*\*(?!\*)(?:(?=[punctuation\s]|$))/,// last char can't be punct,or final * must also be followed by punct (or endline)
      endUnd: /[^\s]__(?!_)(?:(?=[punctuation\s])|$)/ // last char can't be a space,and final _ must preceed punct or \s (or endline)

    },em: {
      start: /^(?:(\*(?=[punctuation]))|\*)(?![*\s])|_/,// (1) returns if starts w/ punctuation
      middle: /^\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*$|^_(?![_\s])(?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?_$/,endAst: /[^punctuation\s]\*(?!\*)|[punctuation]\*(?!\*)(?:(?=[punctuation\s]|$))/,or final * must also be followed by punct (or endline)
      endUnd: /[^\s]_(?!_)(?:(?=[punctuation\s])|$)/ // last char can't be a space,and final _ must preceed punct or \s (or endline)
    },code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br: /^( {2,}|\\)\n(?!\s*$)/,del: noopTest$1,text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation: /^([\s*punctuation])/
  }; // list of punctuation marks from common mark spec
  // without * and _ to workaround cases with double emphasis

解决方法

https://github.com/hexojs/hexo/issues/4501

// node_modules/hexo_prism_plugin/src/index.js
// L8-L14
const map = {
  '&#39;': '\'','&amp;': '&','&gt;': '>','&lt;': '<','&quot;': '"'
};

一种解决方法是

const map = {
  '&#39;': '\'','&quot;': '"','&#123;': '{','&#125;': '}'
};

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。