Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add support for CDATA #3

Closed
wants to merge 4 commits into from

2 participants

Michael J. Ryan Jann Horn
Michael J. Ryan

Add missing event handling for CDATA tags...

Michael J. Ryan and others added some commits
Michael J. Ryan Add CDATA support
Add missing event handling for CDATA tags...
842eb31
Michael J. Ryan Adjust .gitignore
Add node_modules to gitignore, and remove python references.
a706896
Michael J. Ryan tracker1 fix mixed correction
put the cdata in the wrong place...
2cbd2e5
Michael J. Ryan tracker1 fix mixed cdata
put the cdata in the wrong spot.
7a52603
Jann Horn
Owner

The code patch looks good to me and ignoring node_modules is a good idea, but could you please remove all the other things in .gitattributes and .gitignore? Stuff that's specific to your editor or environment rather than node should be in your global gitignore file, not in project-specific files. Also, maybe you could (although it's not necessary) turn all these commits into one for adding some code and one for the gitignore or so, that would result in a cleaner history.

Michael J. Ryan

Honestly, not sure how I would go about undoing the commits... last time I tried, it simply did another commit with the reverted changes. I could do that, and re-do the changes that are needed... without the first couple lines in .gitattributes line endings get fubar'd in windows... can remove the rest in gitignore... not sure where the global prefs are in windows for that... I did the changes at work (windows), and am using github for windows client (believe it's a gui wrapper around the console version.

Michael J. Ryan tracker1 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 7, 2012
  1. Add CDATA support

    Michael J. Ryan authored
    Add missing event handling for CDATA tags...
  2. Adjust .gitignore

    Michael J. Ryan authored
    Add node_modules to gitignore, and remove python references.
Commits on Nov 8, 2012
  1. Michael J. Ryan

    fix mixed correction

    tracker1 authored
    put the cdata in the wrong place...
  2. Michael J. Ryan

    fix mixed cdata

    tracker1 authored
    put the cdata in the wrong spot.
This page is out of date. Refresh to see the latest.
22 .gitattributes
View
@@ -0,0 +1,22 @@
+# Auto detect text files and perform LF normalization
+* text=auto
+
+# Custom for Visual Studio
+*.cs diff=csharp
+*.sln merge=union
+*.csproj merge=union
+*.vbproj merge=union
+*.fsproj merge=union
+*.dbproj merge=union
+
+# Standard to msysgit
+*.doc diff=astextplain
+*.DOC diff=astextplain
+*.docx diff=astextplain
+*.DOCX diff=astextplain
+*.dot diff=astextplain
+*.DOT diff=astextplain
+*.pdf diff=astextplain
+*.PDF diff=astextplain
+*.rtf diff=astextplain
+*.RTF diff=astextplain
137 .gitignore
View
@@ -0,0 +1,137 @@
+#################
+## Eclipse
+#################
+
+*.pydevproject
+.project
+.metadata
+bin/
+tmp/
+*.tmp
+*.bak
+*.swp
+*~.nib
+local.properties
+.classpath
+.settings/
+.loadpath
+
+# External tool builders
+.externalToolBuilders/
+
+# Locally stored "Eclipse launch configurations"
+*.launch
+
+# CDT-specific
+.cproject
+
+# PDT-specific
+.buildpath
+
+
+#################
+## Visual Studio
+#################
+
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+[Dd]ebug/
+[Rr]elease/
+*_i.c
+*_p.c
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.vspscc
+.builds
+*.dotCover
+
+## TODO: If you have NuGet Package Restore enabled, uncomment this
+#packages/
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opensdf
+*.sdf
+
+# Visual Studio profiler
+*.psess
+*.vsp
+
+# ReSharper is a .NET coding add-in
+_ReSharper*
+
+# Installshield output folder
+[Ee]xpress
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish
+
+# Others
+[Bb]in
+[Oo]bj
+sql
+TestResults
+*.Cache
+ClientBin
+stylecop.*
+~$*
+*.dbmdl
+Generated_Code #added for RIA/Silverlight projects
+
+# Backup & report files from converting an old project file to a newer
+# Visual Studio version. Backup files are not needed, because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+
+
+
+############
+## Windows
+############
+
+# Windows image file caches
+Thumbs.db
+
+# Folder config file
+Desktop.ini
+
+
+#############
+## Node.js
+#############
+
+node_modules/
+
+# Mac crap
+.DS_Store
6 index.coffee
View
@@ -27,6 +27,9 @@ exports.createParser = (cbError, cbFinished, wantedNodes, strict) ->
parser.ontext = (text) ->
element?.children.all.push text
element?.children.text.push text
+ parser.oncdata = (text) ->
+ element?.children.all.push text
+ element?.children.text.push text
parser
exports.createStream = (cbError, cbFinished, wantedNodes, strict) ->
@@ -54,4 +57,7 @@ exports.createStream = (cbError, cbFinished, wantedNodes, strict) ->
stream.on "text", (text) ->
element?.children.all.push text
element?.children.text.push text
+ stream.on "cdata", (text) ->
+ element?.children.all.push text
+ element?.children.text.push text
stream
29 index.js
View
@@ -1,3 +1,4 @@
+// Generated by CoffeeScript 1.4.0
(function() {
var last, sax;
@@ -37,7 +38,9 @@
parent.children.tags[name].push(element);
}
}
- if (wantedNodes[name] != null) return interestingStack.push(name);
+ if (wantedNodes[name] != null) {
+ return interestingStack.push(name);
+ }
};
parser.onclosetag = function(name) {
if (name === last(interestingStack)) {
@@ -47,7 +50,15 @@
return element = element != null ? element.parent : void 0;
};
parser.ontext = function(text) {
- if (element != null) element.children.all.push(text);
+ if (element != null) {
+ element.children.all.push(text);
+ }
+ return element != null ? element.children.text.push(text) : void 0;
+ };
+ parser.oncdata = function(text) {
+ if (element != null) {
+ element.children.all.push(text);
+ }
return element != null ? element.children.text.push(text) : void 0;
};
return parser;
@@ -83,7 +94,9 @@
parent.children.tags[name].push(element);
}
}
- if (wantedNodes[name] != null) return interestingStack.push(name);
+ if (wantedNodes[name] != null) {
+ return interestingStack.push(name);
+ }
});
stream.on("closetag", function(name) {
if (name === last(interestingStack)) {
@@ -93,7 +106,15 @@
return element = element != null ? element.parent : void 0;
});
stream.on("text", function(text) {
- if (element != null) element.children.all.push(text);
+ if (element != null) {
+ element.children.all.push(text);
+ }
+ return element != null ? element.children.text.push(text) : void 0;
+ });
+ stream.on("cdata", function(text) {
+ if (element != null) {
+ element.children.all.push(text);
+ }
return element != null ? element.children.text.push(text) : void 0;
});
return stream;
2  package.json
View
@@ -1,5 +1,5 @@
{ "name": "halfstreamxml"
-, "version": "0.2.0"
+, "version": "0.2.1"
, "description": "converts a stream of XML to a stream of objects"
, "keywords":
[ "XML"
Something went wrong with that request. Please try again.