Hi Deathaxe,
I did let go the idea to use a general prototype (as indeed to complex) and worked further on the structure you made extending the html base.
Only for Javascript I am using now a with_prototype clause, because here additional elements can occur nearly anywhere in the code.
A Blogger theme also has simple selfclosing data: tags. Code was easy to add.
For the Blogger tags inside Javascript I made a dedicated context to assure that also between begin and ending tag, the Javascript code was highlighted in the right way.
The CSS embedded in the skin tag is actually some SCSS code but with variables and operations that are always between parenthesis. A small (nonsensical) example beneath to clarify. Do you have any idea of the type of preprocessor code this is or is it some dedicated Googlish thing ?
<b:skin version='1.0.0'><![CDATA[
iframe.b-hbp-video{
border:0
}
.post-body iframe,.post-body img{
max-width:100%
}
.post-body a[imageanchor=\31]{
display:inline-block
}
.bg-photo{
background:$(body.background);
background-attachment:scroll;
background-size:cover;
-webkit-filter:blur($(body.background.blur));
filter:blur($(body.background.blur));
height:calc(100% + 2 * $(body.background.blur) - $(body.background.offset.y));
position:absolute;
top:calc(0px - $(body.background.blur) + $(body.background.offset.y));
}
@media screen and (max-width:$(sidebar.width + content.width * 1.2 - 1px)){
.bg-photo{
left:$(0 - body.background.blur);
width:calc(100% + 2 * $(body.background.blur))
}
.byline{
font:$(robotoNormal15);
margin-$endSide:1em
}
.byline:last-child{
margin-$endSide:0
}
}
.dialog input[type=email],.dialog input[type=text]{
background-color:transparent;
border:0;
border-bottom:1px solid rgba($(body.text.color.red),$(body.text.color.green),$(body.text.color.blue),.12);
color:$(body.text.color);
display:block;
font-family:$(body.text.font.family);
}
.dialog input[type=email]::-webkit-input-placeholder,.dialog input[type=text]::-webkit-input-placeholder{
color:$(body.text.color)
}
]]></b:template-skin>
.
Beside this, the only thing to find out more is if there is an easy way to highlight encoded Javascript/HTML/…, as in:
<b:includable id='postMetadataJSONPublisher'>
"publisher": {
"@type": "Organization",
"name": "Blogger",
"logo": {
"@type": "ImageObject",
"url": "https://lh3.googleusercontent.com/ULB6iBuCeTVvSjjjU1A-O8e9ZpVba6uvyhtiWRti_rBAs9yMYOFBujxriJRZ-A=h60",
"width": 206,
"height": 60
}
},
</b:includable>
<b:widget-setting name='content'><div style="height: 164px; width: 264px; margin: -16px -8px -20px -8px; overflow: visible;">
<div style="height: 66px; width: 250px; margin: -12px 0 0; position: absolute; z-index: 2; overflow: hidden;">
<a class="weatherwidget-io" href="https://forecast7.com/nl/51d053d72/belgium/" data-font="Roboto" data-mode="Current" data-theme="pure" data-scale="0.8">
</a>
<script>
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src='https://weatherwidget.io/js/widget.min.js';fjs.parentNode.insertBefore(js,fjs);}}(document,'script','weatherwidget-io-js');
</script>
</div>
<div style="height: 320px; width: 242px; margin: -22px 0 0 8px; transform-origin: 0 0; transform: scale(1,0.8); position: relative; top: 34px;">
<a class="weatherwidget-io" href="https://forecast7.com/nl/60d021d17/belgium/" data-font="Roboto" data-mode="Forecast" data-theme="pure" data-days="7" data-scale="1" >
</a>
<script>
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[1];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src='https://weatherwidget.io/js/widget.min.js';fjs.parentNode.insertBefore(js,fjs);}}(document,'script','weatherwidget-io-js');
</script>
</div>
</div></b:widget-setting>
<b:widget-setting name='content'><script type="text/javascript">
//################ Function Start
function mbtlist(json) {
document.write('<ul class="mbtlist">');
for (var i = 0; i < ListCount; i++) {
//################### Variables Declared
var listing = ListImage = ListUrl = ListTitle = ListImage = ListContent = ListConten = ListAuthor = ListTag = ListDate = ListUpdate = "";
var ListComments = thumbUrl = TotalPosts = sk = AuthorPic= ListMonth = Y = D = M = m = YY = DD = MM = mm = TT = "";
// .........
if (showTotal == 'on') {
document.write("<div class='itotal'><span> <a href='"+ListBlogLink+"/search/label/"+ListLabel+"'>View all <font>"+TotalPosts+"</font> posts in → " +ListLabel+" </a></span></div>");
}
document.write("</ul>");
}
document.write("<script src='"+ListBlogLink+"/feeds/posts/default/"+ListLabel+"?alt=json-in-script&callback=mbtlist'></"+"script>");
</script>
.
And so finally the .sublime-syntax file I coded with your much apreciated help:
%YAML 1.2
---
name: Google Blogger Theme
version: 2
file_extensions:
- xml
# Use builtin HTML as a base syntax and add rules to handle Blogger tags and inclusions.
scope: text.html.google-blogger-theme
extends: Packages/HTML/HTML.sublime-syntax
contexts:
###[ ADAPT HTML ]#############################################################
tag-other:
# Prepend rules to existing context defined in HTML.sublime-syntax
# which contain rules for <b: ...> and <data: ...> tags.
- meta_prepend: true
- include: blogger-skin-tags
- include: blogger-data-tags
- include: blogger-other-tags
comment:
# Prepend rules to existing context defined in HTML.sublime-syntax
# which contain rules for <-- ...> comment tags.
- meta_prepend: true
- include: dtcs-comment
###[ ADAPT EMBEDDED JAVASCRIPT ]##############################################
script-javascript:
# Overwrite existing context defined in HTML.sublime-syntax
# to contain rules for <b: ...>, <data: ...> and other tags.
- meta_scope: meta.tag.script.begin.html
- include: script-common
- match: '>'
scope: punctuation.definition.tag.end.html
set:
- include: script-close-tag
- include: script-javascript-content-blogger
script-javascript-content-blogger:
# use modified context from HTML.sublime-syntax to contain
# rules for <b: ...>, <data: ...> and other tags.
- match: ""
push: Packages/JavaScript/JavaScript.sublime-syntax
with_prototype:
- include: script-javascript-encapsulation
- include: comment
- match: '{{script_close_lookahead}}'
pop: 1
- include: blogger-js-embed-tags
- include: blogger-data-tags
- include: quote-escaped
script-javascript-encapsulation:
- match: (//)\s*((<!\[)(CDATA)(\[))
captures:
1: comment.line.double-slash.js punctuation.definition.comment.js
2: meta.tag.sgml.cdata.html
3: punctuation.definition.tag.begin.html
4: keyword.declaration.cdata.html
5: punctuation.definition.tag.begin.html
- match: (//)\s*(]]>)
captures:
1: comment.line.double-slash.js punctuation.definition.comment.js
2: meta.tag.sgml.cdata.html punctuation.definition.tag.end.html
###[ B:SKIN TAGS ]############################################################
blogger-skin-tags:
- match: (<)(b)(:)((?:template-)?skin){{tag_name_break}}
captures:
1: punctuation.definition.tag.begin.html
2: entity.name.tag.namespace.html
3: entity.name.tag.html punctuation.separator.namespace.html
4: entity.name.tag.blogskin.html
push: blogger-skin-attributes
- match: (</)(b)(:)((?:template-)?skin){{tag_name_break}}
captures:
1: punctuation.definition.tag.begin.html
2: entity.name.tag.namespace.html
3: entity.name.tag.html punctuation.separator.namespace.html
4: entity.name.tag.blogskin.html
push: blogger-skin-closing
blogger-skin-attributes:
- meta_scope: meta.tag.blogskin.begin.html
- match: '>'
scope: punctuation.definition.tag.end.html
set: blogger-skin-body
- include: tag-end-self-closing
- include: tag-attributes
blogger-skin-body:
- meta_content_scope: meta.blogger.skin.html
- match: (?=</b:\4)
pop: 1
- include: blogger-skin-cdata
blogger-skin-closing:
- meta_scope: meta.tag.blogskin.end.html
- include: tag-end
blogger-skin-cdata:
- match: (<!\[)(CDATA)(\[)
captures:
0: meta.tag.sgml.cdata.html
1: punctuation.definition.tag.begin.html
2: keyword.declaration.cdata.html
3: punctuation.definition.tag.begin.html
embed_scope: meta.tag.sgml.cdata.html
embed: blogger-skin-cdata-content
escape: ']]>'
escape_captures:
0: meta.tag.sgml.cdata.html punctuation.definition.tag.end.html
blogger-skin-cdata-content:
# Include SCSS with HTML supporting comments prepended.
- include: blogger-skin-cdata-comment
- include: Packages/Sass/Syntaxes/SCSS.sublime-syntax
apply_prototype: true
# This context is copied from CSS.sublime-syntax to add html support to comments.
blogger-skin-cdata-comment:
# empty block comment
- match: (/\*+)(\*/)
scope: comment.block.css
captures:
1: punctuation.definition.comment.begin.css
2: punctuation.definition.comment.end.css
# normal block comment
- match: /\*+
scope: punctuation.definition.comment.begin.css
push: blogger-skin-cdata-comment-content
# This context is copied from CSS.sublime-syntax to add html support to comments.
blogger-skin-cdata-comment-content:
- meta_scope: comment.block.css
- match: \*+/
scope: punctuation.definition.comment.end.css
pop: 1
- match: ^\s*(\*)(?!/)
captures:
1: punctuation.definition.comment.css
- include: main
###[ DATA: TAGS ]#############################################################
blogger-data-tags:
- match: (<)(data)(:)
captures:
1: punctuation.definition.tag.begin.html
2: entity.name.tag.namespace.html
3: entity.name.tag.html punctuation.separator.namespace.html
push: blogger-data-attribute
blogger-data-attribute:
- meta_scope: meta.tag.blogdata.begin.html
- match: '>'
scope: punctuation.definition.tag.end.html
- include: tag-end-self-closing
- include: tag-attributes
###[ B:OTHER TAGS EMBEDDED IN JS ]############################################
blogger-js-embed-tags:
- match: (<)(b)(:)({{tag_name}})
captures:
1: punctuation.definition.tag.begin.html
2: entity.name.tag.namespace.html
3: entity.name.tag.html punctuation.separator.namespace.html
4: entity.name.tag.blogger.html
push: blogger-js-embed-attributes
- match: (</)(b)(:)({{tag_name}})
captures:
1: punctuation.definition.tag.begin.html
2: entity.name.tag.namespace.html
3: entity.name.tag.html punctuation.separator.namespace.html
4: entity.name.tag.blogger.html
push: blogger-js-embed-closing
blogger-js-embed-attributes:
- meta_scope: meta.tag.blogger.begin.html
- match: '>'
scope: punctuation.definition.tag.end.html
set: blogger-js-embed-body
- include: tag-end-self-closing
- include: tag-attributes
blogger-js-embed-body:
- meta_content_scope: meta.blogger.any.javascript
- match: (?=</b:\4)
pop: 1
- include: script-javascript-content-blogger
blogger-js-embed-closing:
- meta_scope: meta.tag.blogger.end.html
- match: '>'
scope: punctuation.definition.tag.end.html
pop: 3
###[ B:OTHER TAGS ]###########################################################
blogger-other-tags:
- match: (<)(b)(:)({{tag_name}})
captures:
1: punctuation.definition.tag.begin.html
2: entity.name.tag.namespace.html
3: entity.name.tag.html punctuation.separator.namespace.html
4: entity.name.tag.blogger.html
push: blogger-other-attributes
- match: (</)(b)(:)({{tag_name}})
captures:
1: punctuation.definition.tag.begin.html
2: entity.name.tag.namespace.html
3: entity.name.tag.html punctuation.separator.namespace.html
4: entity.name.tag.blogger.html
push: blogger-other-closing
blogger-other-attributes:
- meta_scope: meta.tag.blogger.begin.html
- match: '>'
scope: punctuation.definition.tag.end.html
set: blogger-other-body
- include: tag-end-self-closing
- include: tag-attributes
blogger-other-body:
- meta_content_scope: meta.blogger.any.html
- match: (?=</b:\4)
pop: 1
- include: blogger-other-embedded
- include: comment
- include: tag
- include: quote-escaped
blogger-other-closing:
- meta_scope: meta.tag.blogger.end.html
- match: '>'
scope: punctuation.definition.tag.end.html
pop: 1
blogger-other-embedded:
- match: ((<!\[)(CDATA)(\[))
captures:
1: meta.tag.sgml.cdata.html
2: punctuation.definition.tag.begin.html
3: keyword.declaration.cdata.html
4: punctuation.definition.tag.begin.html
push:
- match: ']]>'
scope: meta.tag.sgml.cdata.html punctuation.definition.tag.end.html
pop: 1
- match: \s*(?=<)
embed_scope: meta.tag.sgml.cdata.html source.html.embedded.html
embed: Packages/HTML/HTML.sublime-syntax
escape: (?=]]>)
- match: \s*(?=\S)
embed_scope: meta.tag.sgml.cdata.html source.json.embedded.html
embed: Packages/JSON Key-Value/JSON Key-Value.tmLanguage
escape: (?=]]>)
###[ ENCODED LINES ]##########################################################
quote-escaped:
- match: (&#)(39)(;)
captures:
1: constant.character.entity.number.html punctuation.definition.entity.html
2: constant.character.entity.number.html
3: constant.character.entity.number.html punctuation.terminator.entity.html
push:
- match: (?=\S)
push:
- match: (&#)(39)(;)
captures:
1: constant.character.entity.number.html punctuation.definition.entity.html
2: constant.character.entity.number.html
3: constant.character.entity.number.html punctuation.terminator.entity.html
pop: 2
- include: blogger-data-tags
- include: blogger-js-embed-tags
# still to do: < " >
###[ DEDICATED COMMENT TAGS ]#################################################
dtcs-comment:
- match: (<!--)\s*(\*dtcs\*)(-?>)?
captures:
1: punctuation.definition.comment.begin.html
2: dtcs.mark1
3: invalid.illegal.bad-comments-or-CDATA.html
push: dtc-comment-content
dtc-comment-content:
- meta_scope: dtcs.comment
- include: comment-content
.
Would be nice if there was also a way to extend a .sublime-color-scheme file with some additional scopes … (or is there ?)
Any advise on the code always welcome !
Greetings,
Bart.