cscott / instaview

A Mediawiki to HTML converter in JavaScript; packaged for node and volo.
Other
8 stars 6 forks source link

HTML parsing in wikitext #1

Open aqibmushtaq opened 11 years ago

aqibmushtaq commented 11 years ago

There's a problem I've encountered when parsing a wiki image.

(1) The following for-loop is calling shift one too many times and as a result the following stack trace is thrown. (2) Also HTML tags are not supported in the wikitext parser therefore before pushing 'last_attr' to the 'attr' array you should check whether it is 'undefined'.

(1)-----------------------------------------------------------------------------------

315 of main.js : for (;attr.length; attr.shift())

FIX: for (var i = 0; i < attr.length; i++) {

ALSO:

(2)-----------------------------------------------------------------------------------

310 of main.js : attr.push(last_attr);

FIX: if (last_attr) { attr.push(last_attr); }


Stack trace: TypeError: Cannot call method 'match' of undefined at parse_image (/Users/aqib.mushtaq/git/coolstuff/hi-ext-kb-webservice/node_modules/instaview/main.js:325:26) at parse_inline_images (/Users/aqib.mushtaq/git/coolstuff/hi-ext-kb-webservice/node_modules/instaview/main.js:458:13) at parse_inline_wiki (/Users/aqib.mushtaq/git/coolstuff/hi-ext-kb-webservice/node_modules/instaview/main.js:499:9) at parse_inline_nowiki (/Users/aqib.mushtaq/git/coolstuff/hi-ext-kb-webservice/node_modules/instaview/main.js:415:17) at Object.InstaView.convert (/Users/aqib.mushtaq/git/coolstuff/hi-ext-kb-webservice/node_modules/instaview/main.js:593:7) at Object.exports.buildArticle (/Users/aqib.mushtaq/git/coolstuff/hi-ext-kb-webservice/builders/wiki.js:18:34) at Query. (/Users/aqib.mushtaq/git/coolstuff/hi-ext-kb-webservice/handlers/handler.js:173:31) at Query.EventEmitter.emit (events.js:96:17) at Query.RowDataPacket (/Users/aqib.mushtaq/git/coolstuff/hi-ext-kb-webservice/node_modules/mysql/lib/protocol/sequences/Query.js:152:10) at Protocol._parsePacket (/Users/aqib.mushtaq/git/coolstuff/hi-ext-kb-webservice/node_modules/mysql/lib/protocol/Protocol.js:153:14)


Wiki article: {{Other Integration}} [[Category:Other Integrations]]

= Change Management Integration with Outlook =

ServiceNow's Change Management application can send your pending changes to your Microsoft Outlook Calendar automatically. This functionality is controlled by a script in the '''change events''' business rule.

== What Does It Look Like? ==


[[Image:Sample calendar.gif|Image:sample_calendar.gif]] == How Does It Work? ==

Outlook uses the standard iCalendar data format, which is simply a standardized way to describe a calendar event. Events in this format can be sent from a meeting originator (ServiceNow) to a meeting attendee (that's you) as specially formatted emails. So when a change request is assigned to you, ServiceNow will automatically send you an iCalendar-formatted email. You'll see the meeting request inside of Outlook, and you can click '''accept''' to add it to your calendar.

If you've turned on Calendar Integration, you'll be informed every time:

You're assigned to a schedulable change A schedulable change of yours gets reassigned to somebody else *A change gets rescheduled for a different time

Note the deliberate use of the phrase ''schedulable change''. A change needs a start date and an end date before it can be scheduled properly, otherwise it isn't considered ''schedulable'' and therefore won't show up in Outlook. == How Do I Turn It On? ==

You can decide on a per user basis whether change requests assigned to that user are sent to their Outlook calendar. Naturally, if they don't use Outlook, you might not want to turn this option on. Even if they do have Outlook, they may prefer to not receive calendar updates.

To turn Outlook integration on:

Open the user record for the user for whom you want to enable this feature.

Change the '''Calendar Integration''' field from '''-- None --''' to '''Outlook'''.

:You may need to add this field to your User Record by personalizing the form.

Save the record.

From that point on, any changes assigned to that user will generate calendar integration messages via email. == Common Questions and Answers ==

''If I change the start or end of a change in Outlook, will ServiceNow be updated?''

:No, it won't. Currently this is a one-way integration. ServiceNow can send scheduled events to Outlook, but the reverse is not true.

''Does this integration work with other email clients?''

:Yes. While we've only tested with Outlook 2003 and 2007, this integration should work with any email client that supports the iCalendar format.

''What about older versions of Outlook like Outlook 2000?''

:There are known issues with Microsoft's Outlook 2000 ICalendar support. Many of these issues (though not all) can be resolved by installing Microsoft patches. == Business Rule ==

The following is the "change events" business rule associated with this enhancement:

if (current.start_date.changes() || current.end_date.changes() || current.assigned_to.changes()) { if (!current.start_date.nil() && !current.end_date.nil() && !current.assigned_to.nil()) { gs.eventQueue("change.calendar.notify", current, current.assigned_to, previous.assigned_to);

}

// Remove from previous assigned to, due to assigned_to changing if (!previous.assigned_to.nil()) { if (!current.assigned_to.nil() && current.assigned_to.changes() && (!previous.start_date.nil() && !previous.end_date.nil())) { gs.eventQueue("change.calendar.notify.remove", current, current.assigned_to, previous.assigned_to); }

}

// Remove old calendar from current assigned to, due to date changing else if (!current.assigned_to.nil()) { if ((current.start_date.changes() && !previous.start_date.nil()) || (current.end_date.changes() && !previous.end_date.nil())) { gs.eventQueue("change.calendar.notify.remove", current, current.assigned_to, current.assigned_to); }

}

}

cscott commented 11 years ago

Can you prepare a patch and submit a pull request?

(I've been focusing on wikimedia's Parsoid project, which does a much better job translating wikitext -- but it's much more heavyweight.)