Line break in FastApi schema extra - swagger

I am trying to add an example for an endpoint in FastAPI (according to https://fastapi.tiangolo.com/it/tutorial/schema-extra-example/) and one of the fields needs a multiline comment but however I try I am not able to do it. What should I add to get it to multiple lines.
I have tried:
Multiline python string (\n)
<br>
<br />
\ at the end of the line
two spaces at the end of the line
nothing has worked, the Swagger UI displays the raw string no matter what I do.

Related

markdown link to header

I'm using GitLab to write a read.me file.
I tried to create a link to a header. According to the wiki an id should be automatically created:
see here
I created a header using:
### 1. This is my Header
and tried to create a link to it:
[link](#1--this-is-my-header)
but it is not working.
What am I doing wrong?
In the Documentation you link to we learn that...
The IDs are generated from the content of the header according to the
following rules:
All text is converted to lowercase.
All non-word text (e.g., punctuation, HTML) is removed.
All spaces are converted to hyphens.
Two or more hyphens in a row are converted to one.
If a header with the same ID has already been generated, a unique incrementing number is appended, starting at 1.
Note rule 4: "Two or more hyphens in a row are converted to one." However, the example you tried has two hyphens in a row (after the 1). Remove one of them and you should have it.
[link](#1-this-is-my-header)
From time to time I have encountered a unique header which is converted into an ID in some non-obvious way. A quick way to work out the ID is to use your browser's view source and/or inspect tools to view the HTML source code. For example, you might find the following HTML for your example:
<h3 id="1-this-is-my-header">1. This is my Header</h3>
Then just use the contents of the id attribute with a hash to link to that header: #1-this-is-my-header.
Markdown IDs are generated using some rules i've been able to google: (text to lowercase, non-word punctuation removed, spaces converted to hyphens, two or more hyphens in a row converted to one, naming collisions have incremented number appended, ...)
I found an easy way to figure out what the anchor link should be. Use your browser's HTML inspector to inspect the header you want to link to. The header tag's ID should be what you use. So for example my heading looks like this in the HTML inspector:
<h2 id="markdown-header-changing-plsql-parameters-and-shared-developers-lifecycle">
Changing PL/SQL parameters and shared developer's lifecycle
</h2>
And I can link to it in markup like so:
[See instructions below](#markdown-header-changing-plsql-parameters-and-shared-developers-lifecycle)
And now "See instructions below" is linked to my header anchor.
There is a simpler way than the inspector, at least in GitLab-flavored mardown : hover over the header and a "chain" icon appears : right-click on it and copy the link.
header with clickable chain

Mandrill Adding a Space to a URL

Using Mandrill I'm sending an email that has a link:
<a href="http://www.slotted.co/NzIyNnx0c2NvdHRAc2xvdHRlZC5jbw==">
http://www.slotted.co/NzIyNnx0c2NvdHRAc2xvdHRlZC5jbw==
</a>
As expected Mandrill replaces my HREF with a tracking link:
http://mandrillapp.com/track/click/30319089/www.slotted.co?p=eyJzIjoiT1h4VE04RlV2bWp5R2YzNjZkNnNWaFpOemJ3IiwidiI6MSwicCI6IntcInVcIjozMDMxOTA4OSxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvd3d3LnNsb3R0ZWQuY29cXFwvTnpJeU5ueDBjMiBOdmRIUkFjMnh2ZEhSbFpDNWpidz09XCIsXCJpZFwiOlwiM2NmMWE4MzUzNGE1NDg4ZTg1OTUwMDkxZmFhY2M5NTNcIixcInVybF9pZHNcIjpbXCI3YWM1ODFiMTJkY2E0YWM4YzZlMmM3ZDU2OWU2YzQ5MmMxNDIxMDJmXCJdfSJ9
This link redirects to:
http://www.slotted.co/NzIyNnx0c2%20NvdHRAc2xvdHRlZC5jbw==
Notice the extra %20 in the middle of the path which obviously breaks the link. You can try it yourself.
Seems like a bug, but I'm still on the free plan, so no way to report it. Any suggestions?
See this answer:
We typically see this kind of issue with SMTP libraries or frameworks
that generate HTML with no true line breaks. The SMTP specs state that
the line length for email shouldn't exceed 1000 characters. When that
limit is reached, a line break gets inserted automatically when the
message data is being transmitted over SMTP. This unfortunately often
happens right in the middle of a word or a URL, for example. You'll
want to take a look at your SMTP library to see if you can modify how
line breaks are being handled.
If you're using HTML line breaks like <br> that are being used to
indicate a break, those unfortunately won't help in this case. Adding
your own line breaks (not HTML line breaks, but actual line breaks in
the data such as a newline or end of line - usually \r\n - will help
ensure that the forced line breaks aren't arbitrarily added in the
SMTP conversation in inconvenient places.

Undo email wordwrap line breaks in Ruby

My Rails app processes incoming emails by splitting them into multiple lines. This is what I currently use on the plain text version of the body: lines = email.body.split("\n")
This works well unless the sentences are longer than ~74 characters as most email clients will automatically add a line break per RFC 2822.
Example email: https://gist.github.com/marckohlbrugge/39c17b928eb17d330d63
Looking at the plain text part there seems to be no way to discern between a line break added by the user versus the email client. You could ignore any line break happening at the 75th position, but I think there might be a chance of false positives. (I could be wrong.)
The HTML part has all the information we need, but I'm not sure about a universal way to process this. Is replacing every div and br with a newline and then stripping al other HTML elements enough? What about all the other block-element tags? What about inline elements styled as block-elements? What if an email doesn't have an HTML part?
I did find some interesting code examples in Convert HTML to plain text (with inclusion of s), but replacing a list of html tags with newlines doesn't seem like a complete (exhaustive) solution.
Is it worth looking at something like this mail library as they've probably already thought about the edge cases? ;)

grails i18n line break

Using the Grails internationalization messages.properties I'm trying to create a multi-line message, but cannot seem to find a way to create a new line without using the <br> element, and I'd prefer to keep presentation logic out of the message. I've tried using "\n" but that doesn't get rendered.
I know I can use multiple messages "message.1=...", "message.2=...", but that doesn't seem as clean either.
Here's what I'd like to be able to do:
messages.properties
helptext=First Line\nSecond Line\nThird Line
page.gsp
<g.message code="helptext"/>
result:
First Line
Second Line
Third Line
Everything I've found either says to use <br> element, or do a replaceAll on \n, but I was hoping to not have to use extra processing to handle this.
I think you have to use <br> in the message directly.
//messages.properties
helptext=First Line<br>Second Line<br>Third Line
//Gsp
<p><g:message code="helptext"/><p>
\ gives the ability to break the line in the properties file but renders as a single line in view.
For me (i18n message properties in Grails 2.0 project) worked following line:
property = Line1\\nLine2\\nLine3
HTML tag BR worked also fine if displayed on HTML page, but was not any good for me, because I in my case this text needed to be a text string not HTML.
You could write a custom tag that converts \n into br tags as well. It would just need to call the messageSource bean and parse the results. Thus your messages would not have to be HTML-specific

Grails: User inputs formatted string, but formatting not preserved

I am just starting a very basic program in Grails (never used it before, but it seems to be very useful).
What I have so far is:
in X.groovy,
a String named parameters, with constraint of maximum length 50000 and a couple other strings and dates, etc.
in XController.groovy,
static scaffold = X;
It displays the scaffold UI (very handy!), and I can add parameter strings and the other objects associated with it.
My problem is that the parameters string is a long string with formatting that is pasted in by the user. When it is displayed on the browser, however, it does not retain any carriage returns.
What is the best way to go about this? I'm a very beginner at Grails and still have lots and lots of learning to do on this account. Thanks.
The problem is that the string is being displayed using HTML which doesn't parse \n into a new line by default. You need to wrap the text in <pre> (see: http://www.w3schools.com/tags/tag_pre.asp) or replace the \n with <br/> tags to display it correctly to the user.

Resources