In an SCSS file, which output style(s) (nested, expanded, compact or compressed) will remove multiline (/* I'm a comment. */) comments from the final CSS?
:compressed is the only output style which will remove multi-line (/* ... */) comments from the final rendered CSS.
Additionally, :compact will turn a multi-line comment into a single line in the final CSS. With :nested and :expanded, all multi-line comments and their line breaks are rendered in the final CSS.
For example, this SCSS:
// SL Comment
/* ML Comment1
Whoop. */
//! SL w/ bang
/*! ML Comment2
Whoop. */
will become the following CSS for each different output style:
Nested:
/* ML Comment1
Whoop. */
/* ML Comment2
Whoop. */
Expanded:
/* ML Comment1
Whoop. */
/* ML Comment2
Whoop. */
Compact:
/* ML Comment1 Whoop. */
/* ML Comment2
Whoop. */
Compressed:
/* ML Comment2
Whoop. */
Beginning a comment with ! only affects multi-line comments in :compressed mode, where they will be preserved when they would otherwise be removed from the final CSS.
Even with output style "compressed", I have not been able to remove multi-line comments, and the sass/scss documentation also suggests that they are not removed (only single-line comments with "//" are removed).
My solution was to simply apply a Perl one-liner to manually remove comments from a .css file, after sass has generated its final output:
sass -fCE utf-8 -t compressed application.sass application.css
perl -pi -e'BEGIN{$/=undef}s#/\*.*?\*/##gs' application.css
It's a shame I can't downvote or comment on the accepted answer. As per the doc's, what was written and accepted is simply untrue. Sass only removes single line codes and preserves multiline comments.
Sass supports standard multiline CSS comments with /* */, as well as single-line comments with //. The multiline comments are preserved in the CSS output where possible, while the single-line comments are removed.
See here for the docs.
Related
I would like to make my own markup language. How can I do that?
For example, I have a file named 'example.timl'.
Inside the file:
$h1$ Heading $\h1$
- This is my own markup language.
I can define my syntaxes here.
$o_list$
One
Two
Three
Four
Five
$\o_list$
$u_list$
One
Two
Three
Four
Five
$\u_list$
$math$
#inf# + 1 = #inf#
$\math$
\\an_input\\: $input type: 'text'$
\\an_input\\
$code lang: 'py'$
print('Would like to have Python syntax highlighting here.')
$code$
$script$
/* I want to have JS scripts just like HTML */
$\script$
And the rendered output can be as I wished.
As Markup Formatting Reference states, you can use *,+ or - characters as prefixes for markup keywords. For example, take a look at Parameter:
Now, when I try to use *, markup doesn't work:
/**
* Parameter piece: A piece to validate.
* Parameter matchBlock: Called only if necessary.
*/
init(piece: MSPiece?, matchBlock: MatchBlock) { ... }
The above code results in:
But if we put + or - instead of *,
/**
+ Parameter piece: A piece to validate.
- Parameter matchBlock: Called only if necessary.
*/
init(piece: MSPiece?, matchBlock: MatchBlock) { ... }
The documentation will be correct:
Why doesn't * work? It would be actually cool to use an asterisk because /** */ comment stats and ends with asterisk and it would be really neat.
It was a bug and it's fixed in Xcode 10.0.
In non-Doxygen comments, I often have:
/* Lorem ipsum etc.
*
* Notes:
* - A first note.
* - Some other note note.
*/
But with Doxygen, I have #note (or \note), not #notes). So, should I use multiple #notes, or do I put all notes under the same #note?
The #note command results in a paragraph which format can be customized in the CSS file or in the style file when using Latex. So you can just use the markups like in a "normal" text:
/**
* Bla bla...
*
* #note Even in a note you can use markups:
* - Your first note
* - Youre second note
*
* The note section ends with an empty line or the end of the comment.
*/
You can do it either way; it's really a question of style/preference.
As you pointed out, Doxygen has the #note command, but not #notes. You can create your own command for #notes by editing the Doxyfile, and modifying the ALIASES = tag to read
ALIASES = "notes=#par Notes:\n"
With this, you can put the command #notes in the documentation, which will result in a user-defined paragraph with the heading
Notes:
As pointed out in the Doxygen documentation for the ALIAS tag, you can put \n's in the value part of an alias to insert newlines.
I'm facing an issue with CKEditor 4, I need to have an output without any html entity so I added config.entities = false; in my config, but some appear when
an inline tag is inserted: the space before is replaced with
text is pasted: every space is replaced with even with config.forcePasteAsPlainText = true;
You can check that on any demo by typing
test test
eg.
Do you know how I can prevent this behaviour?
Thanks!
Based on Reinmars accepted answer and the Entities plugin I created a small plugin with an HTML filter which removes redundant entities. The regular expression could be improved to suit other situations, so please edit this answer.
/*
* Remove entities which were inserted ie. when removing a space and
* immediately inputting a space.
*
* NB: We could also set config.basicEntities to false, but this is stongly
* adviced against since this also does not turn ie. < into <.
* #link http://stackoverflow.com/a/16468264/328272
*
* Based on StackOverflow answer.
* #link http://stackoverflow.com/a/14549010/328272
*/
CKEDITOR.plugins.add('removeRedundantNBSP', {
afterInit: function(editor) {
var config = editor.config,
dataProcessor = editor.dataProcessor,
htmlFilter = dataProcessor && dataProcessor.htmlFilter;
if (htmlFilter) {
htmlFilter.addRules({
text: function(text) {
return text.replace(/(\w) /g, '$1 ');
}
}, {
applyToAll: true,
excludeNestedEditable: true
});
}
}
});
These entities:
// Base HTML entities.
var htmlbase = 'nbsp,gt,lt,amp';
Are an exception. To get rid of them you can set basicEntities: false. But as docs mention this is an insecure setting. So if you only want to remove , then I should just use regexp on output data (e.g. by adding listener for #getData) or, if you want to be more precise, add your own rule to htmlFilter just like entities plugin does here.
Remove all but not <tag> </tag> with Javascript Regexp
This is especially helpful with CKEditor as it creates lines like <p> </p>, which you might want to keep.
Background: I first tried to make a one-liner Javascript using lookaround assertions. It seems you can't chain them, at least not yet. My first approach was unsuccesful:
return text.replace(/(?<!\>) (?!<\/)/gi, " ")
// Removes but not <p> </p>
// It works, but does not remove `<p> blah </p>`.
Here is my updated working one-liner code:
return text.replace(/(?<!\>\s.)( (?!<\/)|(?<!\>) <\/p>)/gi, " ")
This works as intended. You can test it here.
However, this is a shady practise as lookarounds are not fully supported by some browsers.
Read more about Assertions.
What I ended up using in my production code:
I ended up doing a bit hacky approach with multiple replace(). This should work on all browsers.
.trim() // Remove whitespaces
.replace(/\u00a0/g, " ") // Remove unicode non-breaking space
.replace(/((<\w+>)\s*( )\s*(<\/\w+>))/gi, "$2<!--BOOM-->$4") // Replace empty nbsp tags with BOOM
.replace(/ /gi, " ") // remove all
.replace(/((<\w+>)\s*(<!--BOOM-->)\s*(<\/\w+>))/gi, "$2 $4") // Replace BOOM back to empty tags
If you have a better suggestion, I would be happy to hear 😊.
I needed to change the regular expression Imeus sent, in my case, I use TYPO3 and needed to edit the backend editor. This one didn't work. Maybe it can help another one that has the same problem :)
return text.replace(/ /g, ' ');
if I have a c header file with a doxygen comment:
/*!
* #file MyHeaderFile.h
* #brief Brief header file description
* #author Me Myself
* #date 2012.4.16
*/
This results in html like this:
This same syntax works fine in function comments:
Am I doing something wrong or is this all that is supported?
EDIT: normal function comment:
/*!
* #brief This function does things
*
* #author Me Myself
* #date 2012.4.16
*
* #returns void
*/
void MyFunctionThing(void)
{
}
Although I could not really reproduce the problem given your example, this is most likely the result of Markdown support (introduced in version 1.8.0), in particular the code blocks feature.
Options you can try to avoid/workaround this:
Set MARKDOWN_SUPPORT to NO in the config file
Indent the text in you comment block with less than 4 spaces (after the *).