mirror of
https://github.com/mindoc-org/mindoc.git
synced 2026-02-27 17:03:57 +08:00
upgrade editor.md(many bug exists)
This commit is contained in:
@@ -8,10 +8,10 @@
|
||||
<script src="../../../lib/codemirror.js"></script>
|
||||
<script src="changes.js"></script>
|
||||
<link rel="stylesheet" href="../../../doc/docs.css">
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../../doc/logo.png"></a>
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../../index.html">Home</a>
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="rpm.js"></script>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
|
||||
36
static/editor.md/lib/codemirror/mode/rpm/rpm.js
vendored
36
static/editor.md/lib/codemirror/mode/rpm/rpm.js
vendored
@@ -1,5 +1,5 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
@@ -12,14 +12,14 @@
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("rpm-changes", function() {
|
||||
var headerSeperator = /^-+$/;
|
||||
var headerSeparator = /^-+$/;
|
||||
var headerLine = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ?\d{1,2} \d{2}:\d{2}(:\d{2})? [A-Z]{3,4} \d{4} - /;
|
||||
var simpleEmail = /^[\w+.-]+@[\w.-]+/;
|
||||
|
||||
return {
|
||||
token: function(stream) {
|
||||
if (stream.sol()) {
|
||||
if (stream.match(headerSeperator)) { return 'tag'; }
|
||||
if (stream.match(headerSeparator)) { return 'tag'; }
|
||||
if (stream.match(headerLine)) { return 'tag'; }
|
||||
}
|
||||
if (stream.match(simpleEmail)) { return 'string'; }
|
||||
@@ -34,10 +34,10 @@ CodeMirror.defineMIME("text/x-rpm-changes", "rpm-changes");
|
||||
// Quick and dirty spec file highlighting
|
||||
|
||||
CodeMirror.defineMode("rpm-spec", function() {
|
||||
var arch = /^(i386|i586|i686|x86_64|ppc64|ppc|ia64|s390x|s390|sparc64|sparcv9|sparc|noarch|alphaev6|alpha|hppa|mipsel)/;
|
||||
var arch = /^(i386|i586|i686|x86_64|ppc64le|ppc64|ppc|ia64|s390x|s390|sparc64|sparcv9|sparc|noarch|alphaev6|alpha|hppa|mipsel)/;
|
||||
|
||||
var preamble = /^(Name|Version|Release|License|Summary|Url|Group|Source|BuildArch|BuildRequires|BuildRoot|AutoReqProv|Provides|Requires(\(\w+\))?|Obsoletes|Conflicts|Recommends|Source\d*|Patch\d*|ExclusiveArch|NoSource|Supplements):/;
|
||||
var section = /^%(debug_package|package|description|prep|build|install|files|clean|changelog|preinstall|preun|postinstall|postun|pre|post|triggerin|triggerun|pretrans|posttrans|verifyscript|check|triggerpostun|triggerprein|trigger)/;
|
||||
var preamble = /^[a-zA-Z0-9()]+:/;
|
||||
var section = /^%(debug_package|package|description|prep|build|install|files|clean|changelog|preinstall|preun|postinstall|postun|pretrans|posttrans|pre|post|triggerin|triggerun|verifyscript|check|triggerpostun|triggerprein|trigger)/;
|
||||
var control_flow_complex = /^%(ifnarch|ifarch|if)/; // rpm control flow macros
|
||||
var control_flow_simple = /^%(else|endif)/; // rpm control flow macros
|
||||
var operators = /^(\!|\?|\<\=|\<|\>\=|\>|\=\=|\&\&|\|\|)/; // operators in control flow macros
|
||||
@@ -55,8 +55,8 @@ CodeMirror.defineMode("rpm-spec", function() {
|
||||
if (ch == "#") { stream.skipToEnd(); return "comment"; }
|
||||
|
||||
if (stream.sol()) {
|
||||
if (stream.match(preamble)) { return "preamble"; }
|
||||
if (stream.match(section)) { return "section"; }
|
||||
if (stream.match(preamble)) { return "header"; }
|
||||
if (stream.match(section)) { return "atom"; }
|
||||
}
|
||||
|
||||
if (stream.match(/^\$\w+/)) { return "def"; } // Variables like '$RPM_BUILD_ROOT'
|
||||
@@ -73,21 +73,29 @@ CodeMirror.defineMode("rpm-spec", function() {
|
||||
if (stream.eol()) { state.controlFlow = false; }
|
||||
}
|
||||
|
||||
if (stream.match(arch)) { return "number"; }
|
||||
if (stream.match(arch)) {
|
||||
if (stream.eol()) { state.controlFlow = false; }
|
||||
return "number";
|
||||
}
|
||||
|
||||
// Macros like '%make_install' or '%attr(0775,root,root)'
|
||||
if (stream.match(/^%[\w]+/)) {
|
||||
if (stream.match(/^\(/)) { state.macroParameters = true; }
|
||||
return "macro";
|
||||
if (stream.match('(')) { state.macroParameters = true; }
|
||||
return "keyword";
|
||||
}
|
||||
if (state.macroParameters) {
|
||||
if (stream.match(/^\d+/)) { return "number";}
|
||||
if (stream.match(/^\)/)) {
|
||||
if (stream.match(')')) {
|
||||
state.macroParameters = false;
|
||||
return "macro";
|
||||
return "keyword";
|
||||
}
|
||||
}
|
||||
if (stream.match(/^%\{\??[\w \-]+\}/)) { return "macro"; } // Macros like '%{defined fedora}'
|
||||
|
||||
// Macros like '%{defined fedora}'
|
||||
if (stream.match(/^%\{\??[\w \-\:\!]+\}/)) {
|
||||
if (stream.eol()) { state.controlFlow = false; }
|
||||
return "def";
|
||||
}
|
||||
|
||||
//TODO: Include bash script sub-parser (CodeMirror supports that)
|
||||
stream.next();
|
||||
|
||||
Reference in New Issue
Block a user