How to format json comments in IntelliJ? - intellij-idea

I need add some json in comment to let the comment clearly. But I found IntelliJ will remove all indentation, so is there plugins or methods let IntelliJ format the json in comment correctly? I have tried to find such plugins but they do not take effect at comment.

Try wrapping your json inside the comment with <pre> tags
Eg:
/*
* <pre>
* {
* json: "value1"
* }
* </pre>
*/
Intellij should ignore formatting alignment for text within <pre> tag in javadoc. (With default code style settings for java).

Related

Make folded multiline comment show first line

I have a question regarding IntelliJ's comment folding.
I have the following comment:
/**
* compileNews() converts the text of TextCompiler.soundAlarm() to audio as speech.mp3
*
* #throws Exception
*/
When I fold it, it looks like:
/**...*/
Is there any way that I can get it to fold and show the first line of the comment?
such like:
/**compileNews() converts the text of TextCompiler.soundAlarm() to audio as speech.mp3*/
The text shown as a placeholder for a folded code fragment is controlled by the IDE; it cannot be changed by the user. See https://youtrack.jetbrains.com/issue/IDEA-144788 for a related YouTrack issue.

How to keep IntelliJ IDEA from rearranging javadoc tags?

/**
* Comment.
*
* <p>Hello
*
* #author me (me#domain.com)
* #version $Id$
* #since 0.1
* #checkstyle ClassDataAbstractionCoupling (500 lines)
* #checkstyle ClassFanOutComplexity (500 lines)
*/
When I reformat my code with Ctrl+Alt+L, the #since is placed after the #checkstyle tags. Is there any way to disable javadoc tag rearrangement on code reformatting?
You can uncheck Enable JavaDoc formatting in Settings/Code Style/Java/JavaDoc, which should fix the problem.
However this means that no other formatting will be performed (wrapping, alignining, etc). I haven't found a way to disable just the rearranging of tags.
You can also use this plugin with disabled JavaDoc formatting in IDEA.
With that combination you still have an asterisk * inserted at newline, and you can configure all generated JavaDoc templates for each part of code.
It also has a feature of upgrade existing JavaDoc.

How do I configure IntelliJ to insert <p> tags into existing javadoc?

I have configured my Android Studio (IntelliJ) to insert <p> characters on empty new lines in javadoc by checking the check box in Preferences > Code Style > Java > JavaDoc.
However, when I apply my formatter to my existing code base (Code > Reformat Code...), the <p> tags are not inserted.
My question is, how do I get the IDE to apply the formatter successfully for javadoc newline <p> tokens?
If you have JavaDoc like this:
/**
* Text
* <- no tag will be added here
* #author foo
*/
The <p/> tag will not be inserted between Text and #author, because it would serve no purpose there. The tags will only be inserted between lines of the description (the first part of the JavaDoc):
/**
* Text 1
* <- <p/> will be inserted on this line after reformat
* Text 2
* <- no tag will be inserted here
* #author foo
*/
I'm not certain if this is the problem you're experiencing. Let me know in the comments if it works for you with multiline description as in the second example or if it doesn't work at all.

Jade render's my html twice

Maybe I'm asking my question wrong since it seems like the answer should be relatively easy to search for. I am parsing some .md files in express and returning the response to a jade template.
= body returns <h1>my content</h1> as a string.
#{body} returns <<h1>my content</h1>><!--<h1-->my content> or effectively:
<
my content #as a styled h1
>my content>
Thanks for any help.
UPDATE FOR CLARITY:
My question is - why is the content returning twice.
why is the content returning twice.
Because with the syntax of #{VARIABLE} Jade replace the variable with the value and interpret it as a HTML tag. For example:
passing a local variable {foo: 'bar'} and this template
#{foo}
generat this HTML
<bar></bar>
So you should pass the content and don't let interpret it by jade using = or != for unbuffered code:
!=body
btw: a whitespace is forbidden between = and the variable!

JUI Autocomplete html-encoded suggestions

jQuery UI starting from version 1.8.4 html-encodes Autocomplete suggestions (according to this issue).
This became a problem for me now. I used to theme the output for the suggestions, but now (if I use version 1.8.4 or higher) Autocomplete just html-encodes my theming. All tags like <b>, <span> are being printed to the user instead of displaying the actual styling.
So the suggestions now look like:
<b>su<b>suggestion
another <b>su<b>suggestion
instead of:
suggestion
another suggesion
I've read about custom data, but I use Yii framework and the output is being generated from certain actions (PHP code).
So, how do I theme the output now?
Thank you!
Better use a HTML plugin
You can use open function from jQuery UI to replace the encoded text.
Here's an example:
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'name'=>"bug",
'source'=>$this->createUrl('/autocomplete'),
// additional javascript options for the autocomplete plugin
'options'=>array(
'open'=> 'js:function(event, ui){
$("ul.ui-autocomplete li a").each(function(){
var htmlString = $(this).html().replace(/</g, "<");
htmlString = htmlString.replace(/>/g, ">");
$(this).html(htmlString);
});
}'
),
));