Feature request: Better code formatting on forum


#1

I have a hard time putting code formatted in a post.

When I post xml it gets swallowed and javascript doesn’t get formatted right.

Can we get better support for that plz?


#2
<ScrollView class="green">
<WrapLayout horizontalAlignment="center">      
    <StackLayout style="margin-left: 10" class="card" width="45%" *ngFor="let recipe of (recipes$ | async)">
        <StackLayout horizontalAlignment="center" (tap)="goToRecipe(recipe.id)">
            <Image [src]="recipe.Image"></Image>            
            <Label class="name" horizontalAlignment="center" textWrap="true" [text]="recipe.Name"></Label>
        </StackLayout>
    </StackLayout>           
</WrapLayout> 

#3

I use the little </> code formatter, are you doing something different?


#4
import { Component, OnInit } from "@angular/core";
import { Observable } from "rxjs/Observable";
import { RecipesService } from "../services/recipes.service";
import { Router, ActivatedRoute } from "@angular/router";

@Component({
    selector: "recipes",
    moduleId: module.id,
    templateUrl: "./recipes.component.html",
})
export class RecipesComponent implements OnInit {
  
  public recipes$: Observable<any>;
  private sub: any;
  category: string;
  title: string;
  
    constructor(private recipeService: RecipesService,
                private activatedRoute: ActivatedRoute,
                private router: Router) 
                { }

    ngOnInit(): void {
        this.sub = this.activatedRoute.params.subscribe((params: any) => {
            this.category = params['category'];
                this.recipes$ = <any>this.recipeService.getRecipes(this.category);
                //title
                switch (this.category)
                {
                case "meat":
                    this.title = "Meat Recipes";
                    break;
                case "soupssalads":
                    this.title = "Soup and Salad Recipes";
                    break;
                case "snacks":
                    this.title = "Snack Recipes";
                    break;
                case "desserts":
                    this.title = "Dessert Recipes";
                    break;
                case "vegetarian":
                    this.title = "Vegetarian Recipes";
                    break;
                case "everythingelse":
                    this.title = "Everything Else";
                    break;
                case "all":
                    this.title = "All Recipes";
                    break;
                default : "Recipes";
                }
        })
    }

     goToRecipe(id: string){
        this.router.navigate(["/recipe", id]);
    }
}


#5

hah, I’ve set the code to use ‘code fences’ instead of indents, I think this is better


#6

@StudderVOF general markdown should work also. It’s what I use on here.

For xml - three backticks to open the codeblock followed by the text xml and then paste your code, next line close with three backticks


#7

Hello all thanksyou so much make me already join here