 // MARK: -
 
 class InternalInlineEquation: InternalRmdChunk, InlineChunk, Equation {
+	init(parser: SyntaxParser, contents: NSAttributedString, range: NSRange) {
+		let pchunk = DocumentChunk(chunkType: .equation, docType: .latex, equationType: .inline,
+								   range: range, innerRange: range, chunkNumber: 1)
+		super.init(parser: parser, chunk: pchunk)
+		// FIXME: this was breaking things
+//		update(text: contents.attributedSubstring(from: range))
+		update(text: NSAttributedString(string: contents.string.substring(from: range)!))
+	}
+
 	init(parser: SyntaxParser, contents: String, range: NSRange) {
 		let pchunk = DocumentChunk(chunkType: .equation, docType: .latex, equationType: .inline,
 								   range: range, innerRange: range, chunkNumber: 1)
 		super.init(parser: parser, chunk: pchunk)
-		textStorage.append(NSAttributedString(string: contents.substring(from: range)!))
+		update(text: NSAttributedString(string: contents.substring(from: range)!))
 	}
 }
 
 class InternalInlineCodeChunk: InternalRmdChunk, InlineChunk, Code {
 	var options: MutableProperty<String>
-	init(parser: SyntaxParser, contents: String, range: NSRange, options: String) {
+	init(parser: SyntaxParser, contents: NSAttributedString, range: NSRange, options: String) {
 		self.options = MutableProperty<String>(options)
 		let pchunk = DocumentChunk(chunkType: .code, docType: .rmd, equationType: .none,
 								   range: range, innerRange: range, chunkNumber: 1)
 		super.init(parser: parser, chunk: pchunk)
-		textStorage.append(NSAttributedString(string: contents.substring(from: range)!))
+		update(text: contents.attributedSubstring(from: range))
 	}
 }
 

				case .none: fatalError()
				case .inline:
					guard let lastChunk = lastTextChunk else { throw ParserError.inlineEquationNotInTextChunk }
					let dchunk = InternalInlineEquation(parser: parser, contents: parser.textStorage.string, range: parserChunk.innerRange)
					lastChunk.inlineElements.append(dchunk)
					attach(chunk: dchunk, to: lastChunk.textStorage)
					lastWasInline = true
				case .display:
					let dchunk = EquationChunk(parser: parser, contents: parser.textStorage.string, range: parserChunk.parsedRange, innerRange: parserChunk.innerRange)
					append(chunk: dchunk)
					lastTextChunk = nil
					lastWasInline = false

		super.init(parser: parser, chunk: pchunk)
		update(text: NSAttributedString(string: contents.substring(from: range)!))
	}

	override var rawText: String {
		var opts = options.value
		if opts.count > 0 { opts = " " + opts }
