In the hCalendar microformat, what markup is allowed in a description? - xhtml

I am working on a calendar application that outputs a list of events in hCalendar format. This includes an element that has a class of "description" which should be used for the event's description. My question is, what markup is allowed in my hCalendar event's description?
I found one example on the hCalendar website that showed a description with <br /> tags in it, but every other example was brief and had no additional markup in the description.

As far as Microformats are concerned, you can use any valid HTML markup in the description (and everywhere else).
However, the iCalendar format, which is often used for extraction of hCalendars, only allows plain text in the description.
Use any markup you need, but be prepared that Microformat parsers will convert it to plain text, so likely only <br>, <p> will work, and other elements will have no effect.

Related

Adding hyperlinks to the Description field

I am a user, not a programmer, whose forthcoming new website on Plone 4 requires adding hyperlinks inside the Description field of pages and folders. This is needed to point specific words to our website Dictionary as we had been doing on EZ Publish for the last 10 years.
Our developer says this can't be done in Plone. I'm looking to help them find how to do this (they don't seem to use English-language forums).
Is there an existing add-on or existing code for this? If not, is it possible to code this in? How? If not, will it become standard in Plone 5?
<a href="http://python.org>Python</a> will not work, as the description-field is ment and used as a meta-information of an item, holding plain-text only, and doesn't allow the usage of html-elements, nor embedded Javascript. That's probably why T. K. Nguyen recommends to provide an additional rich-text-field.
But you can use reStrucuredText instead. Tell your developer to exchange the description-snippet in concerned templates to:
<div tal:define="Std modules/Products.PythonScripts/standard;
restructured_text nocall: Std/restructured_text;"
tal:content="structure python: restructured_text(context.Description())">
</div>
It will transform any word starting with 'http:' or 'https:' to a link, furthermore will also recognize mail-addresses like 'someone#plone.org' and transform them to mail-links (on click opens the user's default mail-client, if available, with the address pre-populated in the 'To'-field).
If you want to have named links, use the reStrucutredText-syntax for the input, like this:
`Check out Python`_, you'll love it.
`Write a mail`_ to someone.
.. _Python: http://www.python.org
.. _Write a mail: someone#example.org
The tricky part is to figure out, which templates are affected, but it's doable of my experience (did it with preserving line-breaks in listing-views, not reStructuredText).
Alternatively use a JS-workaround, as proposed by T. K. Nguyen. Be aware though, that it may break accessibility to some users.
It is possible to customize the description fields to be rich text (HTML) instead of plain text, but it requires a developer.
You can also use JavaScript to look at a description field and replace (for example) any string that starts with "http" with a hyperlink pointing to that URL. Your developer would have to look for examples of such JavaScript code and then would have to know how to register it on your site and then invoke it.
This describes how to do something similar, for PloneFormGen field help text (which is also plain text):
https://designinterventionsystems.com/blog/how-to-make-urls-clickable-in-ploneformgen-field-help-text
It might be easier to have your developer create a new rich-text description field and have all your content types include that new field. That, however, would require that you update the view templates for those modified content types. This is much easier with Dexterity, which ships with Plone 5 and is available for use with Plone 4.x.
imho it's a really bad idea to convert the description field to any richttext (html, rst, md) field. You need to change a hole bunch of templates to avoid html code rendered everywhere.
Example:
search
collections
content
portlets
Addons
The description is also often used as title attribute on links, in those cases you need to convert it to plain/text. And there are several more issues, where you could ran into.
As #T. Kim Nguyen wrote: Consider add a new textfield and show it, where necessary, probably implemented as a Viewlet in the below title slot.
Looking at your current site, it seems like you want this to provide a teaser for each article, which may contain links. If that is the case, then you can find other ways to do this without making the description html.
For instance, if you used collective.cover for your portal/collection pages then a Rich Text Tile would allow you to cut down the the object text to an appropriate size, but still edit it with a Rich Text editor, and keep/insert hyperlinks.

how to add the custom elements in the RTF field of a component in SDL Tridion 2011 Sp1

I want to add custom elements in the source of a Rich Text field in SDL Tridion. Is there any chance to add them by changing the XSL filtering in the Schema?
Example:
I have a RTF field "text" in SDL Tridion. I want to add something like this:
<text>
<customelement>the text added through the custom element</customelement>
</text>
Can somebody help me on this?
Thanks.
I'm assuming you're trying to add some HTML5 element in your rich text field.
If you don't want to modify any Tridion installation files, which is something you should try to avoid at all times you could try the following:
Include a CSS class in your rich text field options.
Let the users put the css class on a div, span or anchor tag in your rich text field.
On the front-end with some magic Javascript and jQuery you could try to change the element to the custom element you would like.
Answered previously here
This might introduce issues that are beyond the scope of Tridion support, so you better be ready to support this yourself.
It is probably not necessary to do this. I suspect you should be focussing on your templated output instead.
The standard way for Tridion to store your data in an RTF is as XML in the XHTML namespace. This does not mean that your output needs to comply with this format, any more than the output from a plain text field would need to be plain text.
If you want to have special kinds of data within an RTF field, I would suggest that you use a standard XHTML element, and configure a custom style sheet so that the end users can select the element, and then apply the "specialness" by selecting a class. This is probably a much nicer user experience than having to edit the source tab.
In your templating, you can simply transform these elements into your desired output. I'd suggest using XSLT to do this, or perhaps DOM manipulation, depending on the complexity.

the efficient and accurate way of parsing a web html to text field with formating?

i want to parse the web html to flex text field i have three approaches in mind to do soo
to use string function splice etc. to replace tags with the one which text fields can understand but is it too complex and processing over head is there that reduces the efficiency but i have max control to do changes what i needed.
parsing the html to xml and then use this as the text input to text field what about the efficiency and control need to know about from this question.
regular expressions .
which one will be the most suitable in paring the web text.
help required
regards.
I'd suggest to completely change your approach. If you need a simple HTML to be displayed, then you can directly parse it by the flash/flex. In other cases, when you have a complex HTML page(s), then you should use IFrame. That's really simple and efficient approach and could be very useful in your case. Here you can find its description:
Flex and Iframe,Flex Iframe Project site.
Good luck!

What is usefulness of W3C's "Semantic Data Extractor" in semantically correct XHTML CSS Development?

What is the usefulness of W3C's Semantic Data Extractor?
http://www.w3.org/2003/12/semantic-extractor.html
This tool, geared by an XSLT
stylesheet, tries to extract some
information from a HTML semantic rich
document. It only uses information
available through a good usage of the
semantics defined in HTML.
The aim is to show that providing a
semantically rich HTML gives much more
value to your code: using a
semantically rich HTML code allows a
better use of CSS, makes your HTML
intelligible to a wider range of user
agents (especially search engines
bots).
As an aside, it can give clues to user
agents developers on some hooks that
could be interesting to add in their
product.
After checking validation for CSS and HTML. Should i go for Semantic Data Extractor tool.
What it does. and how it can improved our coding.? Is anyone using it?
And i check some site randomly with but with most of sites it gives error
Using org.apache.xerces.parsers.SAXParser
Exception net.sf.saxon.trans.XPathException: org.xml.sax.SAXParseException: The element type "input" must be terminated by the matching end-tag "`</input>`".
org.xml.sax.SAXParseException: The element type "input" must be terminated by the matching end-tag "`</input>`".
Is it possible to get validate every site with this tool?
After checking validation for CSS and HTML. Should i go for Semantic Data Extractor tool.
Probably not
What it does.
Exactly what you quoted from its homepage.
and how it can improved our coding.?
Other then hitting you over the head when you have problems counting heading levels; not a lot.
And i check some site randomly with but with most of sites it gives error
It depends on well formed and sane input.

HTML Sanitization - bad markup?

I've been scanning some off the discussions on sanitizing HTML markup strings for redisplay on a page (e.g. blog comments). In the past I've just unilaterally escaped the markup for re-display.
Does anyone know if there are any solutions out there that go beyond just removing "unsafe" tags?
What if the markup is invalid? For example, how do you prevent and unclosed <b> tag from bold facing all the text that follows it on in on the page?
It seems like Stackoverflow handles this.
Example of unclosed 'b' tag
Thanks.
Stackoverflow either uses textile or something very much like it.
Textile is more or less guaranteed to spit out valid (x)html, ameliorating many typical problems with sanitizing user input.
Check this code:
Sanitize HTML, I think StackOverflow uses it somewhere...
A method to sanitize any potentially
dangerous tags from the provided raw
HTML input using a whitelist based
approach, leaving the "safe" HTML
tags.
The Html Agility Pack is probably a good starting point as it claims to be very tolerant of badly formatted and malformed HTML. On top of that you'll may want to build some rules to do further sanitization. In the end you serialize the obtained DOM back to plain HTML code.
I faced the same problem you did and built such a rule based HTML sanitizer on top of the Html Agility Pack. It allows you to flatten or remove tags, transform tags for example replacing b with strong tags and restrict attribute usage. Take a look at the source code code of the HtmlRuleSanitizer for ideas or just get the NuGet package if you want to be done quickly.

Resources