New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strip html from the event description #53
Conversation
It strips html, but doesn't add any spaces. It works well if surrounding tags are within the content, but looks a little interesting when links are appended to the end of a listing and end up connected to a period from the sentence before. I do not know how or if we want to tackle that. |
|
||
function convertGoogleEvents(data, now = moment()) { | ||
let events = data.map(event => { | ||
const startTime = moment(event.start.date || event.start.dateTime) | ||
const endTime = moment(event.end.date || event.end.dateTime) | ||
|
||
const description = JSDOM.fragment(event.description).textContent.trim() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a blank line after this, please.
I think |
@hawkrives I don't think it's supported in jsdom jsdom/jsdom#1245 |
Darn. We could just replace |
Well, the issue I see is when we have something like a link tag. You can strip all the html, but then it also removes separating white space. You end up with text that has a url concatenated with the previous word or punctuation. |
If you replace the br tag with a space or a newline? |
Not everything with html tags will contain a newline, is my point? |
Yeah, it won't solve everything, but textContent will preserve in-line spaces (ie "some text (link)" will still have the space between text and link), and if we replace p-closing and br tags with \n, that should get us most of the way there? |
I guess. |
|
||
function convertGoogleEvents(data, now = moment()) { | ||
let events = data.map(event => { | ||
const startTime = moment(event.start.date || event.start.dateTime) | ||
const endTime = moment(event.end.date || event.end.dateTime) | ||
const description = JSDOM.fragment(event.description).textContent.trim() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do the simple thing first, and just change this to
let description = event.description.replace('<br>', '\n')
description = JSDOM.fragment(description).textContent.trim()
so that we at least catch the <br>
tags.
7067808
to
e90b6ce
Compare
Closes #52
Closes #32