mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-30 23:16:09 +00:00 
			
		
		
		
	Gestion listes markdown en pdf
This commit is contained in:
		
							parent
							
								
									86b88ac213
								
							
						
					
					
						commit
						a4c4e26308
					
				
					 1 changed files with 47 additions and 7 deletions
				
			
		|  | @ -290,8 +290,8 @@ namespace AideDeJeu.Pdf | ||||||
|                 //    Render(code); |                 //    Render(code); | ||||||
|                 //    break; |                 //    break; | ||||||
| 
 | 
 | ||||||
|                 //case ListBlock list: |                 case ListBlock list: | ||||||
|                 //    Render(list); |                     return Render(list); | ||||||
|                     //break; |                     //break; | ||||||
| 
 | 
 | ||||||
|                 //case ThematicBreakBlock thematicBreak: |                 //case ThematicBreakBlock thematicBreak: | ||||||
|  | @ -302,8 +302,8 @@ namespace AideDeJeu.Pdf | ||||||
|                 //    Render(html); |                 //    Render(html); | ||||||
|                 //    break; |                 //    break; | ||||||
| 
 | 
 | ||||||
|                 //case Markdig.Extensions.Tables.Table table: |                 case Markdig.Extensions.Tables.Table table: | ||||||
|                 //    Render(table); |                     return Render(table); | ||||||
|                     //break; |                     //break; | ||||||
| 
 | 
 | ||||||
|                 default: |                 default: | ||||||
|  | @ -334,6 +334,44 @@ namespace AideDeJeu.Pdf | ||||||
|             //_Document.Add(CreateFormatted(block.Inline, Font.HELVETICA, 0, new Color(0, 0, 0), 20)); |             //_Document.Add(CreateFormatted(block.Inline, Font.HELVETICA, 0, new Color(0, 0, 0), 20)); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         private Phrase Render(ListBlock block) | ||||||
|  |         { | ||||||
|  |             //listScope++; | ||||||
|  | 
 | ||||||
|  |             var views = new Phrase(); | ||||||
|  |             for (int i = 0; i < block.Count(); i++) | ||||||
|  |             { | ||||||
|  |                 var item = block.ElementAt(i); | ||||||
|  | 
 | ||||||
|  |                 if (item is ListItemBlock itemBlock) | ||||||
|  |                 { | ||||||
|  |                     var subviews = this.Render(block, i + 1, itemBlock); | ||||||
|  |                     if (subviews != null) | ||||||
|  |                     { | ||||||
|  |                         views.AddRange(subviews); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             //listScope--; | ||||||
|  |             return views; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         private Phrase Render(ListBlock parent, int index, ListItemBlock block) | ||||||
|  |         { | ||||||
|  |             var stack = new Phrase(); | ||||||
|  | 
 | ||||||
|  |             var subv = this.Render(block.AsEnumerable()); | ||||||
|  |             subv.ToList().ForEach(v => stack.Add(v)); | ||||||
|  | 
 | ||||||
|  |             return stack; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         private Phrase Render(Markdig.Extensions.Tables.Table tableBlock) | ||||||
|  |         { | ||||||
|  |             return null; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         private Phrase CreateFormatted(ContainerInline inlines, iTextSharp.text.Font fontFamily, int fontStyle, iTextSharp.text.Color fontColor) |         private Phrase CreateFormatted(ContainerInline inlines, iTextSharp.text.Font fontFamily, int fontStyle, iTextSharp.text.Color fontColor) | ||||||
|         { |         { | ||||||
|             var phrase = new Phrase(); |             var phrase = new Phrase(); | ||||||
|  | @ -350,7 +388,7 @@ namespace AideDeJeu.Pdf | ||||||
|             } |             } | ||||||
|             return phrase; |             return phrase; | ||||||
|         } |         } | ||||||
|         private Chunk[] CreateChunks(Inline inline, iTextSharp.text.Font fontFamily, int fontStyle, iTextSharp.text.Color fontColor) |         private IEnumerable<Chunk> CreateChunks(Inline inline, iTextSharp.text.Font fontFamily, int fontStyle, iTextSharp.text.Color fontColor) | ||||||
|         { |         { | ||||||
|             switch (inline) |             switch (inline) | ||||||
|             { |             { | ||||||
|  | @ -372,6 +410,8 @@ namespace AideDeJeu.Pdf | ||||||
|                     return new Chunk[] { Chunk.NEWLINE }; |                     return new Chunk[] { Chunk.NEWLINE }; | ||||||
| 
 | 
 | ||||||
|                 case LinkInline link: |                 case LinkInline link: | ||||||
|  |                     return link.SelectMany(x => CreateChunks(x, fontFamily, fontStyle, fontColor)); | ||||||
|  | 
 | ||||||
|                 case CodeInline code: |                 case CodeInline code: | ||||||
| 
 | 
 | ||||||
|                 case HtmlInline html: |                 case HtmlInline html: | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez