CMAttributedStringRenderer.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // CMAttributedStringRenderer.h
  3. // CocoaMarkdown
  4. //
  5. // Created by Indragie on 1/14/15.
  6. // Copyright (c) 2015 Indragie Karunaratne. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. @class CMDocument;
  10. @class CMTextAttributes;
  11. @protocol CMHTMLElementTransformer;
  12. /**
  13. * Renders an attributed string from a Markdown document
  14. */
  15. @interface CMAttributedStringRenderer : NSObject
  16. /**
  17. * Designated initializer.
  18. *
  19. * @param document A Markdown document.
  20. * @param attributes Attributes used to style the string.
  21. *
  22. * @return An initialized instance of the receiver.
  23. */
  24. - (instancetype)initWithDocument:(CMDocument *)document attributes:(CMTextAttributes *)attributes;
  25. /**
  26. * Registers a handler to transform HTML elements.
  27. *
  28. * Only a single transformer can be registered for an element. If a transformer
  29. * is already registered for an element, it will be replaced.
  30. *
  31. * @param transformer The transformer to register.
  32. */
  33. - (void)registerHTMLElementTransformer:(id<CMHTMLElementTransformer>)transformer;
  34. /**
  35. * Renders an attributed string from the Markdown document.
  36. *
  37. * @return An attributed string containing the contents of the Markdown document,
  38. * styled using the attributes set on the receiver.
  39. */
  40. - (NSAttributedString *)render;
  41. @end