Closed mbomb007 closed 5 days ago
I took a look at the NWS alert page and the .cap file and the weird line breaks are coming directly from NWS.
I will still ping @alexander0042 to take a look and see if its possible for the API to manually add in the line breaks.
Since I'm converting the result to HTML anyway, it's easiest for me to just ignore the line breaks and add <br>
after each section. (Rather than replacing \n
with <br>
)
Yea, it's direct from NWS, which is probably why I removed them originally. How is the separation between the sections completed, two consecutive line breaks, or some other tag? I'm thinking that maybe Pirate Weather should keep double line breaks as one, but remove single breaks?
Yea, it's direct from NWS, which is probably why I removed them originally. How is the separation between the sections completed, two consecutive line breaks, or some other tag? I'm thinking that maybe Pirate Weather should keep double line breaks as one, but remove single breaks?
At the moment, it comes back all on one line, and it seems the sections are separated by two spaces instead of one, but I just ignore that and use the asterisks to find where to insert <br><br>
.
Example response description:
The National Weather Service in Sioux Falls has issued a Red Flag Warning for wind and low relative humidity, which is in effect from 1 PM this afternoon to 8 PM CDT this evening. The Fire Weather Watch is no longer in effect. * AFFECTED AREA...In Iowa, Lyon, Sioux and Plymouth. In Minnesota, Lincoln, Lyon, Murray, Nobles, Pipestone and Rock. In Nebraska, Dixon and Dakota. In South Dakota, Brookings, Moody, Minnehaha, Lincoln, Clay and Union. * WINDS...Northwest 15 to 25 mph with gusts up to 35 mph. * RELATIVE HUMIDITY...As low as 18 percent. * IMPACTS...Any fires that develop will likely spread rapidly. Outdoor burning is not recommended.
Checking this morning, I'm seeing formatting like this:
"* WHAT...Northwest winds 20 to 30 mph with gusts up to 55 mph\nexpected.\n\n* WHERE...Rapid City.\n\n* WHEN...From 5 AM early this morning to 5 PM MST Wednesday.\n\n* IMPACTS...Sudden wind gusts can cause drivers to lose control,\nespecially in lightweight or high profile vehicles. Strong winds\ncan cause blowing dust, reduced visibility, and flying debris."
Which is a good example here, since there's two \n
in between sections, but one in between chunks. So from this, I think the formatting logic should be:
\n
-> space
\n\n
-> \n
I'm going to edit the process script and we can see how it looks
A little regex magic and it's live on the dev endpoint! The response changes from:
The following message is transmitted in collaboration with the
South Dakota Department of Agriculture and Natural Resources.
* WHAT...Northwest winds 20 to 30 mph with gusts to 40 to 50 mph.
* WHERE...West of the Gap in Rapid City.
* WHEN...Tuesday morning through Wednesday afternoon.
IMPACTS...The gusty winds will suspend fine dust in the air and
produce poor air quality.
to
The following message is transmitted in collaboration with the South Dakota Department of Agriculture and Natural Resources.
* WHAT...Northwest winds 20 to 30 mph with gusts to 40 to 50 mph.
* WHERE...West of the Gap in Rapid City.
* WHEN...Tuesday morning through Wednesday afternoon.
IMPACTS...The gusty winds will suspend fine dust in the air and produce poor air quality.
Would this work better for you? I think it's the easiest for people to work with, with the least user processing required, so I think it'd be a good solution.
Yes, I think that's the best way to do it, so at least the line breaks are consistently formatted and easy for devs to manipulate.
Describe the bug
Newlines were recently added to weather alerts. They are added in the middle of sentences where they shouldn't be.
Expected behavior
I expect the text to have each section separated by newlines, but not wrap early.
Southwest Minnesota ... Southeast South Dakota
Actual behavior
Example:
Southwest \n Minnesota ... Southeast \n South Dakota
It's like the text is wrapped at a certain column, but since websites are dynamically sized, this wouldn't look good if I replaced the newlines with
<br>
, because the lines would be in the wrong place.API Endpoint
Production
Location
Sioux Falls, SD
Other details
No response
Troubleshooting steps