Permalink
Browse files

containsMarkup logic fix

  • Loading branch information...
1 parent 310e0a6 commit a63d04b4b8989f9d7ae12f08d3069d37d07be3e3 @parisman parisman committed Oct 4, 2009
Showing with 79 additions and 7 deletions.
  1. +2 −1 Classes/Element.m
  2. +8 −5 Classes/ElementParser.m
  3. +1 −1 Demo/Classes/DemoViewController.m
  4. +4 −0 Demo/Demo.xcodeproj/project.pbxproj
  5. +64 −0 Demo/source2.html
View
@@ -283,7 +283,8 @@ -(NSString*)dumpTree{
for (Element* ee = e; ee; ee = [ee parent])
[result appendString: @" "];
[result appendString: [e description]];
- [result appendString: @"\n"];
+ NSString* txt = (e.containsMarkup) ? @"..." : e.contentsText;
+ [result appendFormat: @"%@\n", txt];
e = e.nextElement;
}
return result;
View
@@ -224,11 +224,14 @@ -(id)buildElementTreeWithChunk:(Chunk*)chunk context:(void*)builder{
NSLog(@"found breakpoint");
*/
self.lastChunk = chunk;
- if (![chunk isKind: ChunkKindText])
- lastOpened.containsMarkup = YES;
- if (![chunk isKind: ChunkKindTag]) return self;
- TagChunk* tag = (TagChunk*) chunk;
- if ([tag isCloseTag])
+ TagChunk* tag = [chunk isKind: ChunkKindTag] ? (TagChunk*) chunk : nil;
+
+ if (![chunk isKind: ChunkKindText] && ![tag isCloseTag])
+ [self parentElement].containsMarkup = YES;
+
+ if (!tag)
+ return self;
+ else if ([tag isCloseTag])
[self closeElementWithTag: tag];
else {
Element* element = [[Element alloc] initWithTag: tag caseSensative: mode == ElementParserModeXML];
@@ -36,7 +36,7 @@ - (void)loadView {
- (void)viewDidLoad {
[super viewDidLoad];
/* pre populate source with the source.html file */
- NSString* path = [[NSBundle mainBundle] pathForResource: @"source" ofType: @"html"];
+ NSString* path = [[NSBundle mainBundle] pathForResource: @"source2" ofType: @"html"];
NSStringEncoding encoding;
self.source = [NSString stringWithContentsOfFile: path usedEncoding: &encoding error: NULL];
textView.text = self.source;
@@ -33,6 +33,7 @@
DC65743E1042E7C500BE3D62 /* TxtChunk.m in Sources */ = {isa = PBXBuildFile; fileRef = DC65742C1042E7C500BE3D62 /* TxtChunk.m */; };
DC65743F1042E7C500BE3D62 /* URLParser.m in Sources */ = {isa = PBXBuildFile; fileRef = DC65742E1042E7C500BE3D62 /* URLParser.m */; };
DC903C0610777B8000F65535 /* source.html in Resources */ = {isa = PBXBuildFile; fileRef = DC903C0510777B8000F65535 /* source.html */; };
+ DCBCF2791078D72F00B671ED /* source2.html in Resources */ = {isa = PBXBuildFile; fileRef = DCBCF2781078D72F00B671ED /* source2.html */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -84,6 +85,7 @@
DC65742D1042E7C500BE3D62 /* URLParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = URLParser.h; path = ../Classes/URLParser.h; sourceTree = SOURCE_ROOT; };
DC65742E1042E7C500BE3D62 /* URLParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = URLParser.m; path = ../Classes/URLParser.m; sourceTree = SOURCE_ROOT; };
DC903C0510777B8000F65535 /* source.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = source.html; sourceTree = "<group>"; };
+ DCBCF2781078D72F00B671ED /* source2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = source2.html; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -146,6 +148,7 @@
children = (
2899E5210DE3E06400AC0155 /* DemoViewController.xib */,
DC903C0510777B8000F65535 /* source.html */,
+ DCBCF2781078D72F00B671ED /* source2.html */,
28AD733E0D9D9553002E5188 /* MainWindow.xib */,
8D1107310486CEB800E47090 /* Demo-Info.plist */,
);
@@ -249,6 +252,7 @@
28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */,
2899E5220DE3E06400AC0155 /* DemoViewController.xib in Resources */,
DC903C0610777B8000F65535 /* source.html in Resources */,
+ DCBCF2791078D72F00B671ED /* source2.html in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
@@ -0,0 +1,64 @@
+<html>
+ <ol>
+ <li>1</li>
+ <li>2</li>
+ <li>3</li>
+ <li>4</li>
+ <li>5</li>
+ <li>6</li>
+ <li>7</li>
+ <li>8</li>
+ <li>9</li>
+ <li>10</li>
+ <li>11</li>
+ <li>12</li>
+ <li>13</li>
+ <li>14</li>
+ <li>15</li>
+ <li>16</li>
+ <li>17</li>
+ <li>18</li>
+ <li>19</li>
+ <li>20</li>
+ <li>21</li>
+ <li>22</li>
+ <li>23</li>
+ <li>24</li>
+ <li>25</li>
+ <li>26</li>
+ <li>27</li>
+ <li>28</li>
+ <li>29</li>
+ <li>30</li>
+ <li>31</li>
+ <li>32</li>
+ <li>33</li>
+ <li>34</li>
+ <li>35</li>
+ <li>36</li>
+ <li>37</li>
+ <li>38</li>
+ <li>39</li>
+ <li>40</li>
+ <li>41</li>
+ <li>42</li>
+ <li>43</li>
+ <li>44</li>
+ <li>45</li>
+ <li>46</li>
+ <li>47</li>
+ <li>48</li>
+ <li>49</li>
+ <li>50</li>
+ <li>51</li>
+ <li>52</li>
+ <li>53</li>
+ <li>54</li>
+ <li>55</li>
+ <li>56</li>
+ <li>57</li>
+ <li>58</li>
+ <li>59</li>
+ <li>60</li>
+ </ol>
+</html>

0 comments on commit a63d04b

Please sign in to comment.