NOTE: The current preferred location for bug reports is the GitHub issue tracker.
Bug 573 - iCalendar output support.
iCalendar output support.
Status: RESOLVED INTENTIONAL
Product: Validator.nu
Classification: Unclassified
Component: General
HEAD
All All
: P2 normal
Assigned To: Henri Sivonen
http://svn.whatwg.org/webapps/source?...
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-05-27 14:37 CEST by Henri Sivonen
Modified: 2009-05-27 14:53 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Henri Sivonen 2009-05-27 14:37:45 CEST
Index: source
===================================================================
--- source	(revision 3109)
+++ source	(revision 3110)
@@ -50850,10 +50850,257 @@
 
   <h4>iCalendar</h4>
 
-  <p class="XXX">...</p>
+  <p>Given a node <var title="">node</var> in a <code>Document</code>,
+  a user agent must run the following algorithm to extract any <code
+  title="md-vevent">vevent</code> data represented by that node:</p>
+
+  <ol>
+
+   <li>
+
+    <p>If <var title="">node</var> is not an element that is an <span
+    title="concept-item">item</span> with the type <code
+    title="md-vevent">vevent</code>, then run these substeps:</p>
+
+    <ol>
+
+     <li><p>If <var title="">node</var> has no parent, then there is
+     no event to output. Abort the algorithm, returning
+     nothing.</p></li>
+
+     <li><p>Let <var title="">node</var> be <var title="">node</var>'s
+     parent.</p></li>
+
+     <li><p>Restart the entire algorithm with the new value of <var
+     title="">node</var>.</p></li>
+
+    </ol>
+
+   </li>
+
+   <li><p>Let <var title="">output</var> be an empty string.</p></li>
+
+   <li><p><span>Add an iCalendar line</span> with the type "<code
+   title="">BEGIN</code>" and the value "<code title="">VCALENDAR</code>"
+   to <var title="">output</var>.</p></li>
+
+   <li><p><span>Add an iCalendar line</span> with the type "<code
+   title="">PRODID</code>" and the value equal to a user-agent
+   specific string representing the user agent to <var
+   title="">output</var>.</p></li>
+
+   <li><p><span>Add an iCalendar line</span> with the type "<code
+   title="">VERSION</code>" and the value "<code title="">2.0</code>"
+   to <var title="">output</var>.</p></li>
+
+   <li><p><span>Add an iCalendar line</span> with the type "<code
+   title="">BEGIN</code>" and the value "<code title="">VEVENT</code>"
+   to <var title="">output</var>.</p></li>
+
+   <li><p><span>Add an iCalendar line</span> with the type "<code
+   title="">DTSTAMP</code>" and a value consisting of an iCalendar
+   DATE-TIME string representing the current date and time, with the
+   annotation "<code title="">VALUE=DATE-TIME</code>", to <var
+   title="">output</var>.</p></li>
+
+   <li><p>If there is a property named <code
+   title="md-about">about</code> whose <span
+   title="concept-item-corresponding">corresponding item</span> is
+   <var title="">node</var> and the element of the first such property
+   is a <span title="URL property elements">URL property
+   element</span> and has a <span
+   title="concept-property-value">value</span> that is not an <span
+   title="concept-item">item</span>, <span>add an iCalendar line</span>
+   with the type "<code title="">UID</code>" and that property's
+   <span title="concept-property-value">value</span> as the value to
+   <var title="">output</var>.</p></li>
+
+   <li>
+
+    <p>For each element <var title="">element</var> that has one or
+    more <span>property names</span> and whose <span
+    title="concept-item-corresponding">corresponding item</span> is
+    <var title="">node</var>: for each name <var title="">name</var>
+    in <var title="">element</var>'s <span>property names</span>, run
+    the appropriate set of substeps from the following list:</p>
+
+    <dl>
+
+     <dt>If <var title="">name</var> is equal to the string "<code
+     title="md-about">about</code>"</dt>
+
+     <dt>If the property's <span
+     title="concept-property-value">value</span> is an <span
+     title="concept-item">item</span></dt>
+
+     <dd>
+
+      <p>Skip the property.</p>
+
+     </dd>
+
+
+     <dt>If <var title="">element</var> is a <code>time</code>
+     element</dt>
+
+     <dd>
+
+      <p>Let <var title="">value</var> be the result of stripping
+      all U+002D HYPHEN-MINUS (-) and U+003A COLON (:) characters
+      from the property's <span
+      title="concept-property-value">value</span>.</p>
+
+      <p>If the property's <span
+      title="concept-property-value">value</span> is a <span>valid
+      date string</span> then <span>add an iCalendar line</span>
+      with the type <var title="">name</var> and the value <var
+      title="">value</var> to <var title="">output</var>, with the
+      annotation "<code title="">VALUE=DATE</code>".</p>
+
+      <p>Otherwise, if the property's <span
+      title="concept-property-value">value</span> is a <span>valid
+      global date and time string</span> then <span>add an iCalendar
+      line</span> with the type <var title="">name</var> and the
+      value <var title="">value</var> to <var title="">output</var>,
+      with the annotation "<code
+      title="">VALUE=DATE-TIME</code>".</p>
+
+      <p>Otherwise skip the property.</p>
+
+     </dd>
+
+
+     <dt>Otherwise</dt>
+
+     <dd>
+
+      <p><span>Add an iCalendar line</span> with the type <var
+      title="">name</var> and the value <var title="">value</var> to
+      <var title="">output</var>.</p>
+
+     </dd>
+
+    </dl>
+
+   </li>
+
+   <li><p><span>Add an iCalendar line</span> with the type "<code
+   title="">END</code>" and the value "<code title="">VEVENT</code>"
+   to <var title="">output</var>.</p></li>
+
+   <li><p><span>Add an iCalendar line</span> with the type "<code
+   title="">END</code>" and the value "<code
+   title="">VCALENDAR</code>" to <var title="">output</var>.</p></li>
+
+  </ol>
+
+  <p>When the above algorithm says that the user agent is to <dfn>add
+  an iCalendar line</dfn> consisting of a type <var
+  title="">type</var>, a value <var title="">value</var>, and
+  optinally an annotation, to a string <var title="">output</var>, it
+  must run the following steps:</p>
+
+  <ol>
+
+   <li><p>Let <var title="">line</var> be an empty string.</p></li>
+
+   <li><p>Append <var title="">type</var>, <span>converted to
+   uppercase</span>, to <var title="">line</var>.</p></li>
+
+   <li>
+
+    <p>If there is an annotation:</p>
+
+    <ol>
+
+     <li><p>Append a U+003B SEMICOLON character (;) to <var
+     title="">line</var>.</p></li>
+
+     <li><p>Append the annotation to <var
+     title="">line</var>.</p></li>
+
+    </ol>
+
+   </li>
+
+   <li><p>Append a U+003A COLON character (:) to <var
+   title="">line</var>.</p></li>
+
+   <li><p>Prefix every U+005C REVERSE SOLIDUS character (\) in
+   <var title="">value</var> with another U+005C REVERSE SOLIDUS
+   character (\).</p></li>
+
+   <li><p>Prefix every U+002C COMMA character (,) in <var
+   title="">value</var> with a U+005C REVERSE SOLIDUS character
+   (\).</p></li>
+
+   <li><p>Prefix every U+003B SEMICOLON character (;) in <var
+   title="">value</var> with a U+005C REVERSE SOLIDUS character
+   (\).</p></li>
+
+   <li><p>Replace every U+000D CARRIAGE RETURN U+000A LINE FEED
+   character pair (CRLF) in <var title="">value</var> with a
+   U+005C REVERSE SOLIDUS character (\) followed by a U+006E
+   LATIN SMALL LETTER N.</p></li>
+
+   <li><p>Replace every remaining U+000D CARRIAGE RETURN (CR) or
+   U+000A LINE FEED (LF) character in <var title="">value</var>
+   with a U+005C REVERSE SOLIDUS character (\) followed by a
+   U+006E LATIN SMALL LETTER N.</p></li>
+
+   <li><p>Append <var title="">value</var> to <var
+   title="">line</var>.</p></li>
+
+   <li><p>Let <var title="">maximum length</var> be 75.</p></li>
+
+   <li>
+
+    <p>If and while <var title="">line</var> is longer than <var
+    title="">maximum length</var> Unicode code points long, run the
+    following substeps:</p>
+
+    <ol>
+
+     <li><p>Append the first <var title="">maximum length</var>
+     Unicode code points of <var title="">line</var> to <var
+     title="">output</var>.</p></li>
+
+     <li><p>Remove the first <var title="">maximum length</var>
+     Unicode code points from <var title="">line</var>.</p></li>
+
+     <li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var
+     title="">output</var>.</p></li>
+
+     <li><p>Append a U+000A LINE FEED character (LF) to <var
+     title="">output</var>.</p></li>
+
+     <li><p>Append a U+0020 SPACE character to <var
+     title="">output</var>.</p></li>
+
+     <li><p>Let <var title="">maximum length</var> be 74.</p></li>
+
+    </ol>
+
+   </li>
+
+   <li><p>Append (what remains of) <var title="">line</var> to <var
+   title="">output</var>.</p></li>
+
+   <li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var
+   title="">output</var>.</p></li>
+
+   <li><p>Append a U+000A LINE FEED character (LF) to <var
+   title="">output</var>.</p></li>
+
+  </ol>
+
+  <p class="note">This algorithm can generate invalid iCalendar
+  output, if the input does not conform to the rules described for the
+  <code title="md-vevent">vevent</code> <span>predefined type</span>
+  and <span title="predefined property name">predefined property
+  names</span>.</p> <!-- of course since icalendar doesn't define
+  error handling, this is somewhat problematic. -->
 
-  <!-- prodid and version are required in output -->
-  <!-- value datetime vs date for dtstart, dtend, rdate, exdate; must include new dtstamp -->
 
 
   <h4>BibTeX</h4>