MurhafSousli / ngx-highlightjs

Angular syntax highlighting module
https://ngx-highlight.netlify.app/
MIT License
278 stars 35 forks source link

How to increase tab width #116

Closed suhailkc closed 4 years ago

suhailkc commented 4 years ago

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [x ] question

OS and Version?

macOS ( Catalina)

Versions

Angular CLI: 9.0.1

Repro steps

npm i ngx-highlightjs

import { HighlightModule } from 'ngx-highlightjs'; @NgModule({ imports: [ HighlightModule ] }) export class AppModule { }

Desired functionality

Tab width adjustment

MurhafSousli commented 4 years ago

This is not related to this plugin, you should to open this issue on highlight.js github page. Here is how to pass config to highlight.js

@NgModule({
  imports: [
    HighlightModule
  ],
  providers: [
    {
      provide: HIGHLIGHT_OPTIONS,
      useValue: {
        languages: getHighlightLanguages(),
        config: {
            // <= here goes highlight.js config
        }
      }
    }
  ],
})
export class AppModule {
}
MurhafSousli commented 4 years ago

Yea probably, It could be solved by CSS, but I have no clue

suhailkc commented 4 years ago

Thank your for your answer.

I tried as you are given. But not working.

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { HighlightModule, HIGHLIGHT_OPTIONS } from 'ngx-highlightjs';

export function getHighlightLanguages() {
  return {
    xml: () => import('highlight.js/lib/languages/xml'),
    typescript: () => import('highlight.js/lib/languages/typescript'),
    scss: () => import('highlight.js/lib/languages/scss'),
  };
}

@NgModule({
  declarations: [CodePreviewComponent],
  imports: [
    CommonModule,
    HighlightModule
  ],
  providers: [
    {
      provide: HIGHLIGHT_OPTIONS,
      useValue: {
        languages: getHighlightLanguages(),
        config: {
          tabReplace: '                 '
        }
      }
    }
  ],
})
export class CodePreviewModule { }

The tabReplace configuration not working.

May I need to import anything extra for highlight.js configuration?

suhailkc commented 4 years ago

I have tried CSS for<code> tag. but not working.

tab-size: 10;

MurhafSousli commented 4 years ago

I am sorry, I have no idea, you should consult the original repo