Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'feature/auto-update-html-sibling' into develop

  • Loading branch information...
commit 42cd9cbab36e764f54644d32565917a2edb7e58e 2 parents 8986390 + 9ec7bf0
@rentzsch authored
View
2  MyDocument.h
@@ -1,6 +1,6 @@
/*******************************************************************************
MyDocument.h - <http://github.com/rentzsch/MarkdownLive>
- Copyright (c) 2006-2010 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
+ Copyright (c) 2006-2011 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
Some rights reserved: <http://opensource.org/licenses/mit-license.php>
***************************************************************************/
View
32 MyDocument.m
@@ -1,6 +1,6 @@
/*******************************************************************************
MyDocument.m - <http://github.com/rentzsch/MarkdownLive>
- Copyright (c) 2006-2010 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
+ Copyright (c) 2006-2011 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
Some rights reserved: <http://opensource.org/licenses/mit-license.php>
***************************************************************************/
@@ -88,6 +88,36 @@ - (BOOL)writeToURL:(NSURL*)absoluteURL_ ofType:(NSString*)typeName_ error:(NSErr
error:error_];
}
+ if (result && ![self hasUnautosavedChanges]) {
+ NSURL *markdownFileURL = [self fileURL];
+ NSURL *htmlFileURL = [[markdownFileURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"html"];
+ if ([[NSFileManager defaultManager] fileExistsAtPath:[htmlFileURL path]]) {
+ NSXMLDocument *doc = [[[NSXMLDocument alloc] initWithContentsOfURL:htmlFileURL
+ options:NSXMLNodePreserveAll|NSXMLDocumentTidyXML
+ error:nil] autorelease];
+ if (doc) {
+ NSArray *nodes = [doc nodesForXPath:@"//*[@id=\"markdownlive\"]" error:nil];
+ if ([nodes count] == 1) {
+ NSXMLElement *node = [nodes objectAtIndex:0];
+ NSXMLDocument *markdownDoc = [[[NSXMLDocument alloc] initWithXMLString:[ORCDiscount markdown2HTML:[markdownSource string]]
+ options:NSXMLDocumentTidyHTML
+ error:nil] autorelease];
+ NSArray *markdownNodes = [markdownDoc nodesForXPath:@"/html/body/*" error:nil];
+ [markdownNodes makeObjectsPerformSelector:@selector(detach)];
+ [node setChildren:markdownNodes];
+ NSString *htmlFileContent = [doc XMLStringWithOptions:NSXMLNodePrettyPrint];
+ if ([htmlFileContent hasPrefix:@"<?xml"]) {
+ NSUInteger index = [htmlFileContent rangeOfString:@"\n"].location;
+ htmlFileContent = [htmlFileContent substringFromIndex:index+1];
+ }
+ [htmlFileContent writeToURL:htmlFileURL
+ atomically:YES
+ encoding:NSUTF8StringEncoding
+ error:nil];
+ }
+ }
+ }
+ }
return result;
}
View
2  discount_wrappers/discountWrapper.h
@@ -1,6 +1,6 @@
/*******************************************************************************
discountWrapper.h - <http://github.com/rentzsch/MarkdownLive>
- Copyright (c) 2006-2010 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
+ Copyright (c) 2006-2011 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
Some rights reserved: <http://opensource.org/licenses/mit-license.php>
***************************************************************************/
View
2  discount_wrappers/discountWrapper.m
@@ -1,6 +1,6 @@
/*******************************************************************************
discountWrapper.m - <http://github.com/rentzsch/MarkdownLive>
- Copyright (c) 2006-2010 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
+ Copyright (c) 2006-2011 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
Some rights reserved: <http://opensource.org/licenses/mit-license.php>
***************************************************************************/
View
2  discount_wrappers/markdownWrapper.c
@@ -1,6 +1,6 @@
/*******************************************************************************
markdownWrapper.c - <http://github.com/rentzsch/MarkdownLive>
- Copyright (c) 2006-2010 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
+ Copyright (c) 2006-2011 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
Some rights reserved: <http://opensource.org/licenses/mit-license.php>
***************************************************************************/
View
2  discount_wrappers/markdownWrapper.h
@@ -1,6 +1,6 @@
/*******************************************************************************
markdownWrapper.h - <http://github.com/rentzsch/MarkdownLive>
- Copyright (c) 2006-2010 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
+ Copyright (c) 2006-2011 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
Some rights reserved: <http://opensource.org/licenses/mit-license.php>
***************************************************************************/
View
2  discount_wrappers/mkdioWrapper.c
@@ -1,6 +1,6 @@
/*******************************************************************************
mkdioWrapper.c - <http://github.com/rentzsch/MarkdownLive>
- Copyright (c) 2006-2010 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
+ Copyright (c) 2006-2011 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
Some rights reserved: <http://opensource.org/licenses/mit-license.php>
***************************************************************************/
View
2  discount_wrappers/mkdioWrapper.h
@@ -1,6 +1,6 @@
/*******************************************************************************
mkdioWrapper.h - <http://github.com/rentzsch/MarkdownLive>
- Copyright (c) 2006-2010 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
+ Copyright (c) 2006-2011 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
Some rights reserved: <http://opensource.org/licenses/mit-license.php>
***************************************************************************/
View
2  main.m
@@ -1,6 +1,6 @@
/*******************************************************************************
main.m - <http://github.com/rentzsch/MarkdownLive>
- Copyright (c) 2006-2010 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
+ Copyright (c) 2006-2011 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
Some rights reserved: <http://opensource.org/licenses/mit-license.php>
***************************************************************************/
Please sign in to comment.
Something went wrong with that request. Please try again.