Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 251153 Details for
Bug 460135
support parameters in markdown editor/viewer
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
initial YAML front-matter work
yamlFrontMatter1.txt (text/plain), 6.62 KB, created by
Grant Gayed
on 2015-02-26 15:02:52 EST
(
hide
)
Description:
initial YAML front-matter work
Filename:
MIME Type:
Creator:
Grant Gayed
Created:
2015-02-26 15:02:52 EST
Size:
6.62 KB
patch
obsolete
>diff --git a/bundles/org.eclipse.orion.client.editor/web/orion/editor/textStyler.js b/bundles/org.eclipse.orion.client.editor/web/orion/editor/textStyler.js >index 5545e96..aeb4a32 100644 >--- a/bundles/org.eclipse.orion.client.editor/web/orion/editor/textStyler.js >+++ b/bundles/org.eclipse.orion.client.editor/web/orion/editor/textStyler.js >@@ -781,6 +781,7 @@ > this.name = name; > this.typeId = typeId; > this.styler = styler; >+ this.stylerAdapter = styler.stylerAdapter; > this.parent = parent; > if (initFn) { > initFn(this); >@@ -1677,6 +1678,7 @@ > return { > TextStyler: TextStyler, > Block: Block, >+ PatternManager: PatternManager, > createPatternBasedAdapter: createPatternBasedAdapter > }; > }); >diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/markdownEditor.js b/bundles/org.eclipse.orion.client.ui/web/orion/markdownEditor.js >index d0c62d2..7b9743d 100644 >--- a/bundles/org.eclipse.orion.client.ui/web/orion/markdownEditor.js >+++ b/bundles/org.eclipse.orion.client.ui/web/orion/markdownEditor.js >@@ -25,9 +25,10 @@ > 'orion/webui/littlelib', > 'orion/URITemplate', > 'orion/webui/splitter', >+ 'orion/editor/stylers/text_x-yaml/syntax', > 'orion/metrics', > 'orion/URL-shim' >-], function(i18nUtil, messages, marked, mCommands, mKeyBinding, mAnnotations, mEditor, mTextStyler, mTextUtil, mFileCommands, objects, lib, URITemplate, mSplitter, mMetrics) { >+], function(i18nUtil, messages, marked, mCommands, mKeyBinding, mAnnotations, mEditor, mTextStyler, mTextUtil, mFileCommands, objects, lib, URITemplate, mSplitter, mYAML, mMetrics) { > > var uriTemplate = new URITemplate("#{,resource,params*}"); //$NON-NLS-0$ > var extensionRegex = /\.([0-9a-z]+)(?:[\?#]|$)/i; >@@ -107,7 +108,7 @@ > return string; > } > >- var MarkdownStylingAdapter = function(model, resource, fileClient) { >+ var MarkdownStylingAdapter = function(model, editor, resource, fileClient) { > this.model = model; > this._blocksCache = {}; > this._defBlocks = {}; >@@ -116,6 +117,10 @@ > /* relativize marked's outputLink */ > var resourceURL = new URL(resource, window.location.href); > marked.InlineLexer.prototype.outputLink = filterOutputLink(resourceURL, fileClient, resource.indexOf(":") === -1); //$NON-NLS-0$ >+ >+ /* for styling YAML front-matters */ >+ this._yamlStylerAdapter = new mTextStyler.createPatternBasedAdapter(mYAML.grammars, "orion.yaml", "text/x-yaml"); //$NON-NLS-1$ //$NON-NLS-0$ >+ this._yamlStyler = new mTextStyler.TextStyler(editor.getTextView(), editor.getAnnotationModel(), this._yamlStylerAdapter); > > this._inlinePatterns = []; > var patternIndex = 0; >@@ -155,14 +160,40 @@ > block.seedTokens = null; > } > >- var index = 0; >+ /* handle YAML front-matter specially */ >+ if (!offset) { >+ var match = this._yamlStylerAdapter._findMatch(this._yamlFrontMatterRegex, text, 0); >+ if (match && !match.index) { >+ var endMatch = this._yamlStylerAdapter._findMatch(this._yamlFrontMatterRegex, text, match.length + 1); >+ if (endMatch) { >+ var end = endMatch.index + endMatch[0].length; >+ var newBlock = >+ this._yamlStylerAdapter.createBlock({ >+ start: 0, >+ contentStart: match[0].length, >+ contentEnd: endMatch.index, >+ end: end >+ }, >+ this._yamlStyler, >+ model, >+ block >+ ); >+ newBlock.name = newBlock.typeId = newBlock.elementId = this._YAML_FRONTMATTER; >+ result.push(newBlock); >+ text = text.substring(end); >+ offset = end; >+ } >+ } >+ } >+ > tokens = tokens || marked.lexer(text, markedOptions); >+ var index = 0; > > for (var i = 0; i < tokens.length; i++) { >- var bounds = null, name = null, end = null, newlines = null; >+ var bounds = null, name = null, newlines = null; > var startToken = null, contentToken = null, parentTokens = null, endToken = null; > var seedTokens = null; >- >+ end = null; > name = null; > this._whitespaceRegex.lastIndex = index; > var whitespaceResult = this._whitespaceRegex.exec(text); >@@ -172,7 +203,7 @@ > > if (tokens[i].type === "heading") { //$NON-NLS-0$ > this._atxDetectRegex.lastIndex = index; >- var match = this._atxDetectRegex.exec(text); >+ match = this._atxDetectRegex.exec(text); > var isAtx = match && match.index === index; > var lineEnd = this._getLineEnd(text, index, model); > end = isAtx ? lineEnd : this._getLineEnd(text, index, model, 1); >@@ -541,8 +572,20 @@ > this._onBlocksChanged({oldBlocks: [], newBlocks: rootBlock.getBlocks()}); > }, > /** @callback */ >- parse: function(text, offset, block, _styles, ignoreCaptures) { >+ parse: function(text, offset, startIndex, block, _styles, ignoreCaptures) { > if (!block.typeId) { >+ return; >+ } >+ >+ /* handle YAML front-matter blocks specially */ >+ if (block.typeId === this._YAML_FRONTMATTER) { >+ this._yamlStylerAdapter.parse( >+ text, >+ offset, >+ 0, >+ block, >+ _styles >+ ); > return; > } > >@@ -575,7 +618,7 @@ > > var index = 0; > while (matches.length > 0) { >- var current = matches[0]; >+ current = matches[0]; > matches.splice(0,1); > if (current.result.index < index) { > /* processing of another match has moved index beyond this match */ >@@ -792,6 +835,11 @@ > _generateHTML: function(rootElement, block) { > if (!block.startToken && !block.tokens) { > return; /* likely a block with only tokens for its parent */ >+ } >+ >+ if (block.typeId === this._YAML_FRONTMATTER) { >+ rootElement.innerHTML = ""; >+ return; > } > > /* >@@ -1229,6 +1277,7 @@ > _TYPEID_LISTITEM: "markup.list.item.markdown", //$NON-NLS-0$ > _TYPEID_PARAGRAPH: "markup.other.paragraph.markdown", //$NON-NLS-0$ > _TYPEID_DEF: "meta.link.reference.def.markdown", //$NON-NLS-0$ >+ _YAML_FRONTMATTER: "yamlFrontMatter", //$NON-NLS-0$ > _atxDetectRegex: /\s*#/g, > _blockquoteRemoveMarkersRegex: /^[ \t]*>[ \t]?/gm, > _blockquoteStartRegex: /[ \t]*>[ \t]?/g, >@@ -1239,7 +1288,8 @@ > _newlineRegex: /\n/g, > _orderedListRegex: /\d+\.[ \t]/g, > _spacesAndTabsRegex: /[ \t]*/g, >- _whitespaceRegex: /\s+/g >+ _whitespaceRegex: /\s+/g, >+ _yamlFrontMatterRegex: /^---$/g > }; > > var _imageCache = {}; >@@ -1548,7 +1598,7 @@ > var editor = this._editorView.editor; > var textView = editor.getTextView(); > var annotationModel = editor.getAnnotationModel(); >- this._stylerAdapter = new MarkdownStylingAdapter(this._model, this._metadata.Location, this._fileService); >+ this._stylerAdapter = new MarkdownStylingAdapter(this._model, editor, this._metadata.Location, this._fileService); > this._styler = new mTextStyler.TextStyler(textView, annotationModel, this._stylerAdapter); > > this._editorView.editor.getTextView().addEventListener("Scroll", this._sourceScrollListener); //$NON-NLS-0$
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 460135
: 251153