Rectangle 27 535

Experimentally, I've discovered that you can provide:

  • Single line breaks are ignored; double line breaks open a new paragraph.
  • Single line breaks can be enforced by ending a line with two spaces (similar to Markdown).
<b></b>
<i></i>
<u></u>
<br />
  • I could not find any way to get strikethrough working (neither HTML or Markdown style).
  • A fully-formatted URL such as http://google.com; this appears as a hyperlink. (Beware that trying to use an HTML <a> tag for a custom description does not work and breaks the formatting.)
  • HTML character entities are supported, such as (), () and (); consult this W3 reference for the exhaustive list.
  • UTF-8 encoded characters are supported, such as , , , , , and .
  • Indentation isn't strictly possible, but using a bullet and em space character looks reasonable ( yields "").
  • Emoji are also supported (though on the website depends on the user's OS & browser).
<blockquote></blockquote>
<small></small>
<sup></sup>
<sub></sub>
<font color="#a32345"></font>
  • Some symbols do not appear correctly, such as .
  • All HTML formatting appears as plain text in the website's "What's New" section (i.e. users will see the HTML source).

Is it just me, or font color is not supported anymore? :(

It seems that indeed font color no longer works on the Google Play website. At the moment, it does still appear in the Google Play app.

Does it also work in the "What's New" section?

@Tom All formatting above works in the Google Play app, but I'm afraid only plain text works on the website's "What's New" section.

I would add this link: support.google.com/googleplay/android-developer/answer/ in order to complete the answer. Experiments can help developers to decide / test which description is better, by adding 2 or more variants.

android - Google Play app description formatting - Stack Overflow

android formatting google-play
Rectangle 27 60

Also note that as of today formatting is available for these languages:

Where did you find this information? As per the first comment, XML is meant to be a supported syntax however the command palette doesn't show format code when the file type is set to xml. I can change it to json or c# and the format code option becomes available. It looks to me that XML isn't supported for formatting.

HTML formatting doesn't work well if you have nested span tag or angular directives as element tag.

Hi, I am still not able to format c# code in cs code 1.10 any idea what I could be missing here?

How do you format code in Visual Studio Code (VSCode) - Stack Overflow

code-formatting visual-studio-code
Rectangle 27 56

Also note that as of today formatting is available for these languages:

Where did you find this information? As per the first comment, XML is meant to be a supported syntax however the command palette doesn't show format code when the file type is set to xml. I can change it to json or c# and the format code option becomes available. It looks to me that XML isn't supported for formatting.

HTML formatting doesn't work well if you have nested span tag or angular directives as element tag.

Hi, I am still not able to format c# code in cs code 1.10 any idea what I could be missing here?

How do you format code in Visual Studio Code (VSCode) - Stack Overflow

code-formatting visual-studio-code
Rectangle 27 59

You could use CSS. Setting display:block, or float:left on the images will let you have define your own spacing and format the HTML however you want but will affect the layout in ways that might or might not be appropriate.

Otherwise you are dealing with inline content so the HTML formatting is important - as the images will effectively act like words.

This is my favourite approach. Although, it can lead to sometimes wondering why text isn't showing up if I subsequently forget to define a font size for child elements.

css - Removing whitespace between HTML elements when using line breaks...

html css image
Rectangle 27 59

You could use CSS. Setting display:block, or float:left on the images will let you have define your own spacing and format the HTML however you want but will affect the layout in ways that might or might not be appropriate.

Otherwise you are dealing with inline content so the HTML formatting is important - as the images will effectively act like words.

This is my favourite approach. Although, it can lead to sometimes wondering why text isn't showing up if I subsequently forget to define a font size for child elements.

css - Removing whitespace between HTML elements when using line breaks...

html css image
Rectangle 27 10

  • Use HTML formatting in the label by starting the text with prefix <html><body> (possibly add some in-line styles in the body opening element).
  • Add each line, ending with <br> or <p> (or <li> if adding <ul><li> to the prefix).

can provide a simple example?

BTW - I missed the bit about 'Hyperlink'. For active links you'd need a JEditorPane with an HyperlinkListener attached (example shown in docs. for JEP).

thanks a lot pal.. that was very useful info...

I am just having a small doubt. Can I display content of a file stored on my machine by using this hyperlink in JEditorPane

"Can I display content of a file" It depends what is in the file. A JEP would be well placed to display HTML, TXT, RTF, images of types PNG, JPG & GIF. Not so well placed to load PDF, DOC, ODT.. Alternately, use the HyperlinkEvent as a prompt to call Desktop.open(File). That will work for any file type which has an associated application (e.g. DOC - MS Word, ODT - Open Office Writer..).

java - Append text in JLabel - Stack Overflow

java swing hyperlink jlabel
Rectangle 27 1

For simple HTML formatting, use <p>{{something}}</p>. And the Javascript way is,

<script type="text/javascript">
    var variable  =  "<p>{{something}}</p>";
    document.write(variable);
</script>
{{something}}
{{something|safe}}
{% autoescape on %}

ok suppose a user input like this "<p>hello world</p>",and i actually save the input like "<p>hello world</p>", now i want to render the template with the input,so i did this variable = "<p>hello world</p>",{{variable}}; now the output will be <p>hello world</p>,but i don't want the <p> tag shows up like a text,i need it to be rendered as html tag,that means the output should be "hello world" in a html paragraph tag.

the reason am doing this is because in this way user can formatting their input, so the output will be exactly the same way, just like stack overflow, when u post a question, u format ur input,and it will be published in the same format.

so you want a client side preview right? Then you shouldn't have mixed the {{}} in your question which refers the context variables served from response.

no i get the preview, i used wmd.js , but after user post their question,how to render the server response in the same way???

Then the {{variable|safe}} should work. You better post your exact code. Have you set {% autoescape on %}?

string - how to render django template variable as html? - Stack Overf...

django string django-templates render html
Rectangle 27 2

If you do not need any html formatting, simply change the content-type to text/plain.

If you need html formatting your output should contain a complete html page. In this case surround your output with <pre>, replace newlines with <br> or convert your output in something like a list or table.

Keep line formatting in browser with bash CGI - Stack Overflow

bash browser formatting cgi
Rectangle 27 3

Nope, that's fine. htmlspecialchars() will turn any HTML control character into its entity equivalent (< => etc.), there is no way of injecting anything there.

Excellent, thank you! I've also added an extra bit to the question too... :)

@Jack highlight_string() won't work because you're inside the pre and code blocks. They don't support HTML formatting.

I changed the Code() function to read this: return "".nl2br(htmlspecialchars(highlight_string($code))).""; - sadly, it still doesn't work. I've also tried 'shuffling' the depth of the highlight_string() function (e.g. putting it at the front), but no luck. There are also unusual '1's being output, see screenshot: cl.ly/603f491d7402e06125be - they're definitely not in the Database data.

@Jack the highlight_string function needs to be the outermost one, as you have it in the example in your question.

I really appreciate the help @Pekka, but when I try that this is output: cl.ly/5df1ec7621b4d6984686 - again, a mystery '1' afterwards...

htmlspecialchars - Formatting HTML code to be output in plain text, wi...

php htmlspecialchars
Rectangle 27 22

You are setting msghtml to a plain text message. html ignores whitespace formatting

I haven't used it for a while, but from memory try

$mail->Body    = file_get_contents($newFile);

php - Sending Plain text emails using PHPMailer - Stack Overflow

php email formatting phpmailer plaintext
Rectangle 27 54

Don't do nl2br when you save it to the database. Do nl2br when you're displaying the text in HTML. I can strongly recommend to not store any HTML formatting in the database (unless you're using a rich HTML editor as well, in which case it would be silly not to).

A newline \n will just become a newline in the textarea.

thanks to everyone for their replies. I can now see that its better practice not to add html on the way in to the db but rather apply it if and when needed on the way out :) thank you

@fl3x7 well don't forget you must treat on the way in for security concern :)

@Oddantfr Agreed :) I've just got into the habit of having an include file which covers all page related pre-procesing. So all POST and GET values are cleaned before any page related php is executed.

One thing to point out is to use \n between " (double quotes) instead of ' (single quotes). Otherwise it won't work. Like this: "\n"

php - line breaks in a textarea - Stack Overflow

php html textarea line-breaks nl2br
Rectangle 27 1

There is a simpler solution using HTML formatting:

final String PRE_HTML = "<html><p style=\"text-align: left; width: 230px\">"; 
final String POST_HTML = "</p></html>"; 

tabbedpane.setTitleAt(0, PRE_HTML + "your title" + POST_HTML);
tabbedpane.setTitleAt(2, PRE_HTML + "your title 2" + POST_HTML);

this is the best solution

java - JTabbedPane: tab placement set to LEFT but icons are not aligne...

java swing icons alignment jtabbedpane
Rectangle 27 3

The idea of putting HTML formatting properties on the (view) model is against the idea of MVC to separate view and logic! What if the model would need to different representations in HTML?

@Saintedlama: It's perfectly fine to put data annotations on the viewmodel, because viewmodel's only purpose is to provide a structured data model for the view. Not to be confused with model, which in MVC terminology usually represents a DB entity, which should not have any view-related properties. Having said that, it is unfortunate that his viewmodel annotations start with HTMLxxx because that implies HTML as a presentation layer, but a line has to be drawn somewhere. :) Besides, if he reuses the viewmodel for say silverlight app, he can easily add SL attributes to his viewmodel.

c# - EditorFor() and html properties - Stack Overflow

c# asp.net-mvc asp.net-mvc-2
Rectangle 27 3

The idea of putting HTML formatting properties on the (view) model is against the idea of MVC to separate view and logic! What if the model would need to different representations in HTML?

@Saintedlama: It's perfectly fine to put data annotations on the viewmodel, because viewmodel's only purpose is to provide a structured data model for the view. Not to be confused with model, which in MVC terminology usually represents a DB entity, which should not have any view-related properties. Having said that, it is unfortunate that his viewmodel annotations start with HTMLxxx because that implies HTML as a presentation layer, but a line has to be drawn somewhere. :) Besides, if he reuses the viewmodel for say silverlight app, he can easily add SL attributes to his viewmodel.

c# - EditorFor() and html properties - Stack Overflow

c# asp.net-mvc asp.net-mvc-2
Rectangle 27 5

To specify that a component's text has HTML formatting, just put the tag at the beginning of the text, then use any valid HTML in the remainder. Here is an example of using HTML in a button's text:

button = new JButton("<html><b><u>T</u>wo</b><br>lines</html>");

I updated my question asking how I can format the button's text properly including the html superscript, do you know a good way to do this?

java - Include the minus superscript in a JButton's text - Stack Overf...

java html swing jbutton superscript
Rectangle 27 4

Michael's answer is okay but it will block safe HTML as well as dangerous inputs. This means that any input which contains HTML formatting such as <em> will be displayed with the actual HTML code.

If you want to accept safe HTML but block/filter dangerous inputs, then use a tested, proven 3rd party XSS filtering library like HTMLPurifier: http://htmlpurifier.org/

Don't reinvent the wheel, especially when it comes to security.

c# - Avoiding XSS vulnerabilities - whitelist? - Stack Overflow

c# xss security
Rectangle 27 2

Thank's for the tip! I don't think it's the only solution to this exact problem, but it's cetainly good if I want to allow some HTML formatting.

Let's imagine we have a page with only <?echo strip_tags($_GET['query']);?> in its body. What injections are possible here?

strip_tags()
htmlspecialchars()

@navist, please note - what you wrote is not my use case. I was talking about using strip_tags on INPUTTED data, not OUTPUTTED (displayed) data

php - Is preventing XSS and SQL Injection as easy as does this - Stack...

php html xss sql-injection
Rectangle 27 6

All the above answer will not remove html tag like , etc if the given string contains, I tried to remove all the tags, and this is work fine for me

AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
        builder.setTitle("Title");

        LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.custom_dialog, null);

        TextView text = (TextView) layout.findViewById(R.id.text);
        text.setMovementMethod(LinkMovementMethod.getInstance());
        text.setText(Html.fromHtml("<b>Hello World</b> This is a test of the URL <a href=http://www.example.com> Example</a><p><b>This text is bold</b></p><p><em>This text is emphasized</em></p><p><code>This is computer output</code></p><p>This is<sub> subscript</sub> and <sup>superscript</sup></p>";));
        builder.setView(layout);
AlertDialog alert = builder.show();

and the custom_dialog would be like;

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/layout_root"
              android:orientation="horizontal"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:padding="10dp"
              >

    <TextView android:id="@+id/text"
              android:layout_width="wrap_content"
              android:layout_height="fill_parent"
              android:textColor="#FFF"
              />
</LinearLayout>

The above code will remove all the html tag and shows Example as Click able URL all others in the specified html formatting text.

android - How can I get clickable hyperlinks in AlertDialog from a str...

android user-interface hyperlink custom-controls
Rectangle 27 6

All the above answer will not remove html tag like , etc if the given string contains, I tried to remove all the tags, and this is work fine for me

AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
        builder.setTitle("Title");

        LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.custom_dialog, null);

        TextView text = (TextView) layout.findViewById(R.id.text);
        text.setMovementMethod(LinkMovementMethod.getInstance());
        text.setText(Html.fromHtml("<b>Hello World</b> This is a test of the URL <a href=http://www.example.com> Example</a><p><b>This text is bold</b></p><p><em>This text is emphasized</em></p><p><code>This is computer output</code></p><p>This is<sub> subscript</sub> and <sup>superscript</sup></p>";));
        builder.setView(layout);
AlertDialog alert = builder.show();

and the custom_dialog would be like;

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/layout_root"
              android:orientation="horizontal"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:padding="10dp"
              >

    <TextView android:id="@+id/text"
              android:layout_width="wrap_content"
              android:layout_height="fill_parent"
              android:textColor="#FFF"
              />
</LinearLayout>

The above code will remove all the html tag and shows Example as Click able URL all others in the specified html formatting text.

android - How can I get clickable hyperlinks in AlertDialog from a str...

android user-interface hyperlink custom-controls
Rectangle 27 5

To solve my problem I found an IBM article explaining exactly what I was trying to do: "HTML to Formatting Objects (FO) conversion guide"

It is pretty straightforward but you need to be experienced to pull this off... I'm not so thank you IBM.

xslt - Converting xml/html table to pdf via xsl-fo - Stack Overflow

xslt pdf pdf-generation xsl-fo