Add simple-ext documentation
This commit is contained in:
		
							parent
							
								
									a082e9ed44
								
							
						
					
					
						commit
						eca93dd27c
					
				| @ -1,4 +1,4 @@ | ||||
| 
 | ||||
| // this is a generated file, do not modify. To update it run 'collectArtifacts.js' script
 | ||||
| const artifacts = [{"id":"core","name":"Core","group":"io.noties.markwon","description":"Core Markwon artifact that includes basic markdown parsing and rendering"},{"id":"ext-latex","name":"LaTeX","group":"io.noties.markwon","description":"Extension to add LaTeX formulas to Markwon markdown"},{"id":"ext-strikethrough","name":"Strikethrough","group":"io.noties.markwon","description":"Extension to add strikethrough markup to Markwon markdown"},{"id":"ext-tables","name":"Tables","group":"io.noties.markwon","description":"Extension to add tables markup (GFM) to Markwon markdown"},{"id":"ext-tasklist","name":"Task List","group":"io.noties.markwon","description":"Extension to add task lists (GFM) to Markwon markdown"},{"id":"html","name":"HTML","group":"io.noties.markwon","description":"Provides HTML parsing functionality"},{"id":"image","name":"Image","group":"io.noties.markwon","description":"Markwon image loading module (with optional GIF and SVG support)"},{"id":"image-glide","name":"Image Glide","group":"io.noties.markwon","description":"Markwon image loading module (based on Glide library)"},{"id":"image-picasso","name":"Image Picasso","group":"io.noties.markwon","description":"Markwon image loading module (based on Picasso library)"},{"id":"linkify","name":"Linkify","group":"io.noties.markwon","description":"Markwon plugin to linkify text (based on Android Linkify)"},{"id":"recycler","name":"Recycler","group":"io.noties.markwon","description":"Provides RecyclerView.Adapter to display Markwon markdown"},{"id":"recycler-table","name":"Recycler Table","group":"io.noties.markwon","description":"Provides MarkwonAdapter.Entry to render TableBlocks inside Android-native TableLayout widget"},{"id":"syntax-highlight","name":"Syntax Highlight","group":"io.noties.markwon","description":"Add syntax highlight to Markwon markdown via Prism4j library"}]; | ||||
| const artifacts = [{"id":"core","name":"Core","group":"io.noties.markwon","description":"Core Markwon artifact that includes basic markdown parsing and rendering"},{"id":"ext-latex","name":"LaTeX","group":"io.noties.markwon","description":"Extension to add LaTeX formulas to Markwon markdown"},{"id":"ext-strikethrough","name":"Strikethrough","group":"io.noties.markwon","description":"Extension to add strikethrough markup to Markwon markdown"},{"id":"ext-tables","name":"Tables","group":"io.noties.markwon","description":"Extension to add tables markup (GFM) to Markwon markdown"},{"id":"ext-tasklist","name":"Task List","group":"io.noties.markwon","description":"Extension to add task lists (GFM) to Markwon markdown"},{"id":"html","name":"HTML","group":"io.noties.markwon","description":"Provides HTML parsing functionality"},{"id":"image","name":"Image","group":"io.noties.markwon","description":"Markwon image loading module (with optional GIF and SVG support)"},{"id":"image-glide","name":"Image Glide","group":"io.noties.markwon","description":"Markwon image loading module (based on Glide library)"},{"id":"image-picasso","name":"Image Picasso","group":"io.noties.markwon","description":"Markwon image loading module (based on Picasso library)"},{"id":"linkify","name":"Linkify","group":"io.noties.markwon","description":"Markwon plugin to linkify text (based on Android Linkify)"},{"id":"recycler","name":"Recycler","group":"io.noties.markwon","description":"Provides RecyclerView.Adapter to display Markwon markdown"},{"id":"recycler-table","name":"Recycler Table","group":"io.noties.markwon","description":"Provides MarkwonAdapter.Entry to render TableBlocks inside Android-native TableLayout widget"},{"id":"simple-ext","name":"Simple Extension","group":"io.noties.markwon","description":"Custom extension based on simple delimiter usage"},{"id":"syntax-highlight","name":"Syntax Highlight","group":"io.noties.markwon","description":"Add syntax highlight to Markwon markdown via Prism4j library"}]; | ||||
| export { artifacts }; | ||||
|  | ||||
| @ -65,6 +65,7 @@ module.exports = { | ||||
|                 '/docs/v4/linkify/', | ||||
|                 '/docs/v4/recycler/', | ||||
|                 '/docs/v4/recycler-table/', | ||||
|                 '/docs/v4/simple-ext/', | ||||
|                 '/docs/v4/syntax-highlight/', | ||||
|                 '/docs/v4/recipes.md', | ||||
|                 '/docs/v4/migration-3-4.md' | ||||
|  | ||||
							
								
								
									
										62
									
								
								docs/docs/v4/simple-ext/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								docs/docs/v4/simple-ext/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,62 @@ | ||||
| # Simple Extension <Badge text="4.0.0" /> | ||||
| 
 | ||||
| <MavenBadge4 :artifact="'simple-ext'" /> | ||||
| 
 | ||||
| `SimpleExtPlugin` allows creating simple _delimited_ extensions, for example: | ||||
| 
 | ||||
| ```md | ||||
| +this is text surrounded by `+`+ | ||||
| ``` | ||||
| 
 | ||||
| ```java | ||||
| final Markwon markwon = Markwon.builder(this) | ||||
|         .usePlugin(SimpleExtPlugin.create(plugin -> plugin | ||||
|                 // +sometext+ | ||||
|                 .addExtension(1, '+', new SpanFactory() { | ||||
|                     @Override | ||||
|                     public Object getSpans(@NonNull MarkwonConfiguration configuration, @NonNull RenderProps props) { | ||||
|                         return new EmphasisSpan(); | ||||
|                     } | ||||
|                 }) | ||||
|         .build(); | ||||
| ``` | ||||
| 
 | ||||
| or | ||||
| 
 | ||||
| ```java | ||||
| final Markwon markwon = Markwon.builder(this) | ||||
|         .usePlugin(SimpleExtPlugin.create()) | ||||
|         .usePlugin(new AbstractMarkwonPlugin() { | ||||
|             @Override | ||||
|             public void configure(@NonNull Registry registry) { | ||||
|                 registry.require(SimpleExtPlugin.class, new Action<SimpleExtPlugin>() { | ||||
|                     @Override | ||||
|                     public void apply(@NonNull SimpleExtPlugin plugin) { | ||||
|                         plugin.addExtension(1, '+', new SpanFactory() { | ||||
|                             @Override | ||||
|                             public Object getSpans(@NonNull MarkwonConfiguration configuration, @NonNull RenderProps props) { | ||||
|                                 return new EmphasisSpan(); | ||||
|                             } | ||||
|                         }) | ||||
|                     } | ||||
|                 }); | ||||
|             } | ||||
|         }) | ||||
|         .build(); | ||||
| ``` | ||||
| 
 | ||||
| If opening and closing characters are different another method can be used: | ||||
| 
 | ||||
| ```java | ||||
| plugin.addExtension( | ||||
|     /*length*/2,  | ||||
|     /*openingCharacter*/'@',  | ||||
|     /*closingCharacter*/'$',  | ||||
|     /*spanFactory*/(configuration, props) -> new ForegroundColorSpan(Color.RED)))) | ||||
| ``` | ||||
| 
 | ||||
| This extension will be applied to a text like this: | ||||
| 
 | ||||
| ```md | ||||
| @@we are inside different delimiter characters$$ | ||||
| ``` | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Dimitry Ivanov
						Dimitry Ivanov